Skip to content

Android 15 - Incorrect lineHeight on Text #53307

Closed as not planned
Closed as not planned

Description

@roni-castro-shipt

Description

When running the app in debug mode on Android 15 using the old architecture, text spacing appears incorrect after refreshing the app. I'm noticing that issue also in our Android release app using rn 0.78.3

  • The issue does not occur when using the new architecture.
  • The issue also occurs in React Native 0.81 with the old architecture.
  • It does not occur on Android 13
  • It does not occur on iOS

Steps to reproduce

https://github.com/roni-castro-shipt/rn-android-15-font-issue

  1. npm install
  2. Create an Android 15 emulator or a physical device with that OS version
  3. npm run android
  4. Refresh the app by pressing r in Metro Terminal, or rr inside the app.

React Native Version

0.81.0

Output of npx @react-native-community/cli info

System:
  OS: macOS 15.6
  CPU: (8) arm64 Apple M3
  Memory: 186.89 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.18.1
    path: ~/.nvm/versions/node/v20.18.1/bin/node
  Yarn:
    version: 1.22.22
    path: ~/.nvm/versions/node/v20.18.1/bin/yarn
  npm:
    version: 10.8.2
    path: ~/.nvm/versions/node/v20.18.1/bin/npm
  Watchman:
    version: 2025.06.23.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.14.3
    path: /Users/ronidecastro/.rbenv/shims/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 24.5
      - iOS 18.5
      - macOS 15.5
      - tvOS 18.5
      - visionOS 2.5
      - watchOS 11.5
  Android SDK:
    API Levels:
      - "31"
      - "33"
      - "34"
      - "35"
      - "36"
    Build Tools:
      - 30.0.3
      - 33.0.0
      - 33.0.1
      - 34.0.0
      - 35.0.0
      - 36.0.0
    System Images:
      - android-28 | Google ARM64-V8a Play ARM 64 v8a
      - android-30 | Google APIs ARM 64 v8a
      - android-31 | Google Play ARM 64 v8a
      - android-33 | Google Play ARM 64 v8a
      - android-34 | Desktop ARM 64 v8a
      - android-34 | Android TV ARM 64 v8a
      - android-34 | Google Play ARM 64 v8a
      - android-35 | Wear OS 5.1 - Preview ARM 64 v8a
      - android-35 | Google Play ARM 64 v8a
      - android-35 | Pre-Release 16 KB Page Size Google Play ARM 64 v8a
      - android-35 | Pre-Release 16 KB Page Size Google APIs ARM 64 v8a
      - android-36 | Google Play ARM 64 v8a
    Android NDK: Not Found
IDEs:
  Android Studio: 2025.1 AI-251.25410.109.2511.13665796
  Xcode:
    version: 16.4/16F6
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.13
    path: /usr/bin/javac
  Ruby:
    version: 3.1.4
    path: /Users/ronidecastro/.rbenv/shims/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 20.0.0
    wanted: 20.0.0
  react:
    installed: 19.1.0
    wanted: 19.1.0
  react-native:
    installed: 0.81.0
    wanted: 0.81.0
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false

Screenshots and Videos

weird-spacing-refresh.mp4
android_15_moto_g54.mp4

release app
Image

Activity

  1. react-native-bot commented on Aug 15, 2025

    @react-native-bot
    Collaborator

    Warning

    Could not parse version: We could not find or parse the version number of React Native in your issue report. Please use the template, and report your version including major, minor, and patch numbers - e.g. 0.76.2.

  2. react-native-bot commented on Aug 15, 2025

    @react-native-bot
    Collaborator

    Warning

    Could not parse version: We could not find or parse the version number of React Native in your issue report. Please use the template, and report your version including major, minor, and patch numbers - e.g. 0.76.2.

  3. changed the title [-]Android 15 - Incorrect lineHeight on Text in debug mode[/-] [+]Android 15 - Incorrect lineHeight on Text[/+] on Aug 15, 2025
  4. react-native-bot commented on Sep 12, 2025

    @react-native-bot
    Collaborator

    This issue is waiting for author's feedback since 24 days. Please provide the requested feedback or this will be closed in 7 days.

  5. added
    StaleThere has been a lack of activity on this issue and it may be closed soon.
    on Sep 12, 2025
  6. react-native-bot commented on Sep 19, 2025

    @react-native-bot
    Collaborator

    This issue was closed because the author hasn't provided the requested feedback after 7 days.

  7. removed
    StaleThere has been a lack of activity on this issue and it may be closed soon.
    on Sep 19, 2025
  8. zewillze commented on Sep 22, 2025

    @zewillze

    hello, any solution for this issue?

  9. roni-castro-shipt commented on Sep 23, 2025

    @roni-castro-shipt
    Author

    This could be related to the Android text view changes, and react-native not supporting it correctly. React-native is not supporting legacy architecture anymore, so I don't think they will fix that =/
    This solves the example I shared:

    android/app/src/main/res/values/styles.xml

    <resources>
        <!-- ADD THIS -->
        <!-- Custom TextView style to preserve old behavior -->
        <style name="Widget.App.TextView" parent="Widget.AppCompat.TextView">
            <!-- Prevents Android 15 from allocating extra width for complex shaping. -->
            <item name="android:useBoundsForWidth">false</item>  
        </style>
    
        <!-- Base application theme -->
        <style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
            <!-- Customize your theme here -->
            <item name="android:editTextBackground">@drawable/rn_edit_text_material</item>
            <!-- Apply custom TextView defaults --> <!-- ADD THIS -->
            <item name="android:textViewStyle">@style/Widget.App.TextView</item>  
        </style>
    </resources>
    Screen.Recording.2025-09-23.at.13.16.40.mov

    if it does not solve, try disabling other stuff in there, or try this one, if you also have problems with text input

    <resources>
        <!-- Custom TextView style to preserve old behavior -->
        <style name="Widget.App.TextView" parent="Widget.AppCompat.TextView">
            <!-- Prevents Android 15 from reserving extra vertical metrics -->
            <item name="android:elegantTextHeight">false</item>
            <item name="android:useLocalePreferredLineHeightForMinimum">false</item>
            <!-- Prevents Android 15 from allocating extra width for complex shaping -->
            <item name="android:useBoundsForWidth">false</item>
            <item name="android:shiftDrawingOffsetForStartOverhang">false</item>
        </style>
    
        <!-- Base application theme -->
        <style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
            <!-- Customize your theme here -->
            <item name="android:editTextBackground">@drawable/rn_edit_text_material</item>
            <!-- Apply custom TextView defaults -->
            <item name="android:textViewStyle">@style/Widget.App.TextView</item>
        </style>
    </resources>
    
  10. pierroo commented on Sep 29, 2025

    @pierroo

    FYI it also happens with new architecture, so hopefully RN team looks into it.
    I also created an issue about text being cut:
    #53666

  11. crafts69guy commented on Aug 5, 2026

    @crafts69guy

    The styles.xml override posted in this thread also fixes horizontal clipping, not just the line-height problem — and it turns out italic fonts aren't the only trigger. Full write-up in #53286; the essentials, since they're relevant here:

    Another data point, plus a reusable Expo config plugin for the styles.xml workaround.

    It is not only italic fonts — Vietnamese diacritics hit this too

    The Android 15 docs frame useBoundsForWidth around italics, so this is easy to dismiss if you don't ship an italic face. But it fires for any glyph whose ink overhangs the advance width the font reserves for it, and Vietnamese stacked diacritics qualify: ế, ở, ằ, ữ.

    The symptom that cost us the most time is that it is per-glyph, not per-length, so sibling labels of the same size and font disagree:

    Label Result
    Tất cả fine
    Pha chế → Pha
    Đang mở → Đang
    ĐIỂM ĐỔI QUÀ → ĐIỂM ĐỔI

    It only becomes visible where a container hugs its text (badges, chips, pills). Everywhere else the few missing pixels are absorbed by surrounding space, which makes it look random.

    Because the mismatch is in how the platform measures text, nothing on the JS side fixes it. In case it saves someone the same detour, these all failed for us: flexShrink: 0, numberOfLines={1}, alignSelf: "stretch", extra horizontal padding, embedding the fonts at build time via the expo-font plugin instead of useFonts, and replacing spaces with U+00A0. The last one is worth calling out because it looks like it works — it only converts "drops the last word" into "clips mid-character", since the node is still too narrow.

    Version status (verified against the published tags)

    useBoundsForWidth in TextLayoutManager.kt:

    • 0.83.4 — not present. The highest SDK check in the file is TIRAMISU. (The CHANGELOG lists 8347cc4 under v0.83.2, but it is not in the 0.83.4 tag or the published npm package.)
    • 0.84.0 / 0.85.3 — present, but gated behind ReactNativeFeatureFlags.fixTextClippingAndroid15useBoundsForWidth(), which defaults to false in ReactNativeFeatureFlagsDefaults.kt.

    So upgrading alone does not fix it — on 0.84+ you also have to turn the flag on.

    Workaround as an Expo config plugin

    The styles.xml override posted above works, but Expo projects using CNG (no checked-in android/) can't edit that file directly. This plugin applies it on every prebuild:

    // plugins/with-android-text-metrics.js
    const { withAndroidStyles } = require("expo/config-plugins")
    
    const APP_THEME = "AppTheme"
    const STYLE_NAME = "Widget.App.TextView"
    const ITEMS = {
      "android:useBoundsForWidth": "false",
      "android:elegantTextHeight": "false",
      "android:shiftDrawingOffsetForStartOverhang": "false",
      "android:useLocalePreferredLineHeightForMinimum": "false",
    }
    
    function upsertItem(style, name, value) {
      style.item = style.item ?? []
      const existing = style.item.find((i) => i?.$?.name === name)
      if (existing) existing._ = value
      else style.item.push({ _: value, $: { name } })
    }
    
    module.exports = (config) =>
      withAndroidStyles(config, (c) => {
        const styles = c.modResults
        styles.resources = styles.resources ?? {}
        styles.resources.style = styles.resources.style ?? []
    
        let style = styles.resources.style.find((s) => s?.$?.name === STYLE_NAME)
        if (!style) {
          style = { $: { name: STYLE_NAME, parent: "Widget.AppCompat.TextView" }, item: [] }
          styles.resources.style.push(style)
        }
        for (const [name, value] of Object.entries(ITEMS)) upsertItem(style, name, value)
    
        const theme = styles.resources.style.find((s) => s?.$?.name === APP_THEME)
        if (theme) upsertItem(theme, "android:textViewStyle", `@style/${STYLE_NAME}`)
    
        return c
      })

    Add "./plugins/with-android-text-metrics" to plugins in app.config.js. It is idempotent, so repeated prebuilds don't duplicate entries. Needs a native rebuild — it can't ship over the air.

    Confirmed fixed on device with RN 0.83.4 / Expo SDK 55, new architecture, compileSdk 36.

    Two caveats worth knowing before you copy it:

    • Turning useBoundsForWidth off is a deliberate return to the pre-15 behaviour, which is exactly what Android changed to stop overhanging glyphs being clipped. If you do ship an italic or heavily-overhanging face, check it after applying this.
    • shiftDrawingOffsetForStartOverhang is already the platform default (Android doesn't add the left padding even when targeting 35+), so that line is belt-and-braces rather than load-bearing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    DebuggingIssues related to React Native DevTools or legacy JavaScript/Hermes debuggingNeeds: AttentionIssues where the author has responded to feedback.Platform: AndroidAndroid applications.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions