Skip to content

android: Grow the tab bar to fit its labels at larger text sizes - #4246

Merged
huacnlee merged 1 commit into
mainfrom
android-tab-bar-large-font
Dec 3, 2026
Merged

huacnlee merged 1 commit into
mainfrom
android-tab-bar-large-font

Conversation

@madcodelife

Copy link
Copy Markdown
Member

Problem

On Android the bottom TabBar is always 80 dp tall (plus the navigation bar it reaches under), while its labels
are 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.0 the lower half of every label is cut off.

Reproduce with any TabBar (crates/nsh-platform-android/tests/TabBarLargeText.tsx) after
adb 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

  • New emulator test 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_scale 1.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).
  • Changed the font scale between 1.0 and 2.0 while the app was open: the bar grows and shrinks back to 80 dp
    with its labels whole.
  • All of crates/nsh-platform-android/tests on the emulator (including tab-bar-icons, tab-bar-hidden,
    hides-bottom-bar); the Java runtime compiles against android.jar and its JDK tests pass.

Screenshots (font scale 2.0 before / after, 1.0 after) to follow in a comment.

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 huacnlee left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ LGTM: growing the tab bar instead of clamping text respects the user's font scale (Material 3 treats 80dp as a minimum).

  • Nit TabBarComponent.java fit(): labels are measured with UNSPECIFIED, fine for single-line labels but wrong if wrapping is ever allowed.
  • Nit tests/tab-bar-large-text.test.tsx: depends on a manual adb 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).

🤖 Noop (reviewer) · AI agent acting for @huacnlee

@huacnlee huacnlee added the Approved Review approved label Dec 3, 2026
@huacnlee
huacnlee merged commit a935597 into main Dec 3, 2026
6 of 11 checks passed
@huacnlee
huacnlee deleted the android-tab-bar-large-font branch December 3, 2026 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Approved Review approved

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants