Repository navigation
android: Grow the tab bar to fit its labels at larger text sizes - #4246
Merged
Merged
Conversation
The bar was always 80 dp tall while its labels follow the system font size, so at a font scale of 2.0 the lower half of each label was cut off. The bar now measures its labels and grows past 80 dp when they need it, again when the font scale changes while the app runs.
huacnlee
approved these changes
Dec 3, 2026
huacnlee
left a comment
Member
There was a problem hiding this comment.
✅ LGTM: growing the tab bar instead of clamping text respects the user's font scale (Material 3 treats 80dp as a minimum).
- Nit
TabBarComponent.javafit(): labels are measured withUNSPECIFIED, fine for single-line labels but wrong if wrapping is ever allowed. - Nit
tests/tab-bar-large-text.test.tsx: depends on a manualadb settings put font_scale, so CI only covers 80dp. Please attach before/after screenshots at scale 2.0.
Reviewed head 1e37195 (diff read; CI still pending at review time, verdict holds once it is green).
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.
Problem
On Android the bottom
TabBaris always 80 dp tall (plus the navigation bar it reaches under), while its labelsare sized in sp and follow the system font size. At a larger font scale a label no longer fits the 16 dp the
80 dp bar leaves it: at
font_scale 2.0the lower half of every label is cut off.Reproduce with any
TabBar(crates/nsh-platform-android/tests/TabBarLargeText.tsx) afteradb shell settings put system font_scale 2.0.Change
The bar's height follows its labels: it measures them (down to the text's descent) and grows past Material's
80 dp when they need more, and measures again when the font scale changes while the app runs. At the default
size it stays exactly 80 dp.
Why grow the bar rather than cap the label size: the labels keep the size the user chose, which is what the
font scale setting is for, and Material 3 gives the navigation bar 80 dp as its least height rather than a fixed
one. Capping the scale (around 1.3×) would keep the bar at a constant height, but would make the tab labels the
one piece of text in the app that ignores the setting, and still needs the same measurement for scales up to the
cap.
Tests
crates/nsh-platform-android/tests/tab-bar-large-text.test.tsx(nsh test --target android):at the default size the tabs are 80 dp tall; at 1.5× and more they are taller. Run at
font_scale1.0 and 2.0:on main the 2.0 run fails (
expected 80 to be greater than 80); with this change both pass (API 36 emulator,1.3× gives 85 dp).
with its labels whole.
crates/nsh-platform-android/testson the emulator (includingtab-bar-icons,tab-bar-hidden,hides-bottom-bar); the Java runtime compiles againstandroid.jarand its JDK tests pass.Screenshots (font scale 2.0 before / after, 1.0 after) to follow in a comment.