Fix translucent navbar for Android 10#38
Open
svank wants to merge 1 commit intostfalcon-studio:masterfrom
Open
Fix translucent navbar for Android 10#38svank wants to merge 1 commit intostfalcon-studio:masterfrom
svank wants to merge 1 commit intostfalcon-studio:masterfrom
Conversation
When the status bar is _not_ hidden, past behavior was for the navigation bar to be translucent. On Android 10 (SDK 29), it is opaque black. This patch restores and improves upon past behavior by ensuring a fully transparent nav bar when gesture controls are enabled (and using the system-provided translucent scrim when 3-button navigation is enabled). To achieve this we need to switch from using android:windowTranslucentNavigation to using android:navigationBarColor. On Android 10, it appears android:windowDrawsSystemBarBackgrounds must be set for android:navigationBarColor to have any affect. (I wonder if this is related to being an AlertDialog.) android:windowDrawsSystemBarBackgrounds is not supported in SDK < 21, whereas this library supports SDK >= 19, so I've created a separate styles.xml file for SDK >= 29. Setting systemUiVisibility flags appears to be necessary to get the transparent nav bar effect. It seems that setting android:windowTranslucentNavigation was providing the same effect as setting these flags, but now it needs to be done manually for SDK >= 29 as android:windowTranslucentNavigation is not set.
ab9d815 to
27c248e
Compare
|
Thanks for this PR ! It solved my issue, I copy pasted the code you added in styles.xml (in v29) and it worked for me. |
|
actually, it wasn't translucent for me, I actually added this code on my style.xml for anyone interested: |
hamzasharuf
approved these changes
Nov 26, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When the status bar is not hidden (i.e.
StfalconImageViewer.Builder().withHiddenStatusBar(false)), past behavior was for thenavigation bar to be translucent. On Android 10 (SDK 29), it is opaque
black. See screenshot below, Android 9 on left and Android 10 on right
This patch restores and improves upon past behavior for Android 10 by
ensuring a fully transparent nav bar when gesture controls are enabled
(and using the system-provided translucent scrim when 3-button navigation
is enabled). See screenshot below, Android 9 on left,
Android 10 center and right with three-button and gesture navigation.
I'm not 100% sure I've done this in the optimal way, but here's what I've found:
To achieve this we need to switch from using
android:windowTranslucentNavigation to using android:navigationBarColor.
On Android 10, it appears android:windowDrawsSystemBarBackgrounds
must be set for android:navigationBarColor to have any affect.
(I wonder if this is related to using an AlertDialog.)
android:windowDrawsSystemBarBackgrounds is not supported in SDK < 21,
whereas this library supports SDK >= 19, so I've created a separate
styles.xml file for SDK >= 29.
Setting systemUiVisibility flags appears to be necessary to get
the transparent nav bar effect. It seems that setting
android:windowTranslucentNavigation was providing the same effect
as setting these flags, but now it needs to be done manually for
SDK >= 29 as android:windowTranslucentNavigation is not set.