fix(sample): repair toolbar theming and do an edge-to-edge pass - #668
Merged
Conversation
- toolbar used a white-on-?colorPrimary style, which is invisible under Theme.Material3.DayNight in dark mode; use Widget.Material3.Toolbar.Surface and let M3 resolve the content colors - menu icons hardcoded Color.WHITE, same problem in light mode - drop values-v21/themes.xml: windowTranslucentStatus, statusBarColor and navigationBarColor are no-ops under Android 15 edge-to-edge, and the window transitions it declared were never used - enable edge-to-edge in both activities and apply the insets explicitly
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.
The sample app's toolbar renders blank on recent Android versions:
CustomToolbarStylehardcoded white title/subtitle text on a?colorPrimarybackground, and underTheme.Material3.DayNightin dark modecolorPrimaryis a light tone — white on near-white. The old AppCompat themes had a darkcolorPrimary, M3 inverted it.While in there, the app never got an edge-to-edge pass.
Changes
CustomToolbarStyle/CustomTitleTextAppearance/CustomSubTitleTextAppearanceand thecolorControlNormalwhite override; useWidget.Material3.Toolbar.Surfaceand let M3 resolve content colors per light/dark. Same foractivity_playground.xml's inline?attr/colorPrimary+ThemeOverlay.MaterialComponents.Dark.Color.WHITE→getThemeColor(android.R.attr.textColorPrimary); the hardcoded white had the same invisibility problem in light mode.values-v21/themes.xmldeleted —windowTranslucentStatus,statusBarColorandnavigationBarColorare no-ops under Android 15 edge-to-edge, and the window transitions it declared were unused (nomakeSceneTransitionAnimationanywhere in the sample).minSdkis well above 21, so the qualifier was moot regardless.enableEdgeToEdge()in both activities plus one sharedapplyEdgeToEdgeInsets(root, topView, bottomView)helper: status bar inset onto the toolbar, navigation bar inset onto the scrolling content, horizontal bar/cutout insets onto both.activity_main.xml—fitsSystemWindows="true"on the ConstraintLayout.DrawerLayoutotherwise applies the insets to that child as margins, which boxes the content inside the system bars and defeats edge-to-edge. The slider keeps its ownfitsSystemWindows; MaterialDrawer handles its insets itself.Testing
:app:assembleDebugpasses. Installed on a device — the toolbar title, drawer toggle and menu icons are visible again in both themes, and content draws behind the system bars with correct padding.