Skip to content

Commit c5612b4

Browse files
committed
fix(Android): header shadow not hidden on go back (#2216)
## Description This PR intents to fix header shadow not being hidden after navigating back to a screen. The bug was visible when using `headerTransparent: true` option. The origin of this bug is [This PR](#2116) fixing build depracations. Setting the `elevation` on appBarLayout requires resetting the `stateListAnimator` to work properly, as opossed to deprecated `targetElevation` used before. For more info visit: https://developer.android.com/reference/com/google/android/material/appbar/AppBarLayout#setTargetElevation(float) Fixes #2212 . ## Changes - added missing `appBarLayout?.stateListAnimator` reset. ## Screenshots / GIFs Here you can add screenshots / GIFs documenting your change. You can add before / after section if you're changing some behavior. ### Before ![Screenshot 2024-06-27 at 11 39 50](https://github.com/software-mansion/react-native-screens/assets/91994767/78c42cd3-4523-46f2-93ea-2aa4a6f4da4f) ### After ![Screenshot 2024-06-27 at 11 39 29](https://github.com/software-mansion/react-native-screens/assets/91994767/b0d32daa-ee98-438e-90cb-621bb6b13ad0) ## Test code and steps to reproduce 1. use `Test1097.tsx` repro 2. navigate into second or third screen 3. go back to the first screen ## Checklist - [x] Included code example that can be used to test this change - [x] Ensured that CI passes
1 parent 98ec45e commit c5612b4

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

android/src/main/java/com/swmansion/rnscreens/ScreenStackFragment.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ class ScreenStackFragment :
138138
view?.addView(appBarLayout)
139139
if (isToolbarShadowHidden) {
140140
appBarLayout?.elevation = 0f
141+
appBarLayout?.stateListAnimator = null
141142
}
142143
toolbar?.let { appBarLayout?.addView(recycleView(it)) }
143144
setHasOptionsMenu(true)

0 commit comments

Comments
 (0)