Skip to content

After upgrading the Android targetSdkVersion to 35, the TextInput text is no longer vertically centered when typing on Android 15. #52775

Closed as not planned

Description

@BS3385

Description

I upgraded React Native from version 0.73.2 to 0.80.1 and also updated the targetSdkVersion to 35. After the upgrade, I noticed that when entering text in the TextInput component, the text is vertically shifted upwards, while the cursor remains vertically centered.

Here’s the style I was using:

style={{
  backgroundColor: '#eee',
  height: 40,
  paddingTop: 10,
  paddingBottom: 10,
  lineHeight: 20,
  fontSize: 16,
  includeFontPadding: true,
  textAlignVertical: 'center',
}}

The result looks like this:
Image

However, if I change the style to:

style={{
  backgroundColor: '#eee',
  height: 40,
  lineHeight: 40,
  fontSize: 16,
}}

The result looks like this:
Image

And if I remove the height:

style={{
  backgroundColor: '#eee',
  lineHeight: 40,
  fontSize: 16,
}}

The result looks like this:

Image

Steps to reproduce

1、Updated the targetSdkVersion to 35
2、Write the following components

<TextInput
    keyboardType="numeric"
    placeholderTextColor="#999"
    style={{
        backgroundColor: '#eee',
        height: 40,
        paddingTop: 10,
        paddingBottom: 10,
        lineHeight: 20,
        fontSize: 16,
        includeFontPadding: true,
        textAlignVertical: 'center',
    }}
/>

3、Running on Android 15(My phone is Xiaomi 15)

React Native Version

0.80.1

Affected Platforms

Runtime - Android

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

System:
  OS: macOS 15.4.1
  CPU: (8) arm64 Apple M1 Pro
  Memory: 135.30 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 18.18.0
    path: ~/.nvm/versions/node/v18.18.0/bin/node
  Yarn:
    version: 4.9.2
    path: ~/.nvm/versions/node/v18.18.0/bin/yarn
  npm:
    version: 9.8.1
    path: ~/.nvm/versions/node/v18.18.0/bin/npm
  Watchman:
    version: 2024.08.12.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.15.2
    path: /usr/local/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 24.2
      - iOS 18.2
      - macOS 15.2
      - tvOS 18.2
      - visionOS 2.2
      - watchOS 11.2
  Android SDK: Not Found
IDEs:
  Android Studio: 2022.3 AI-223.8836.35.2231.10671973
  Xcode:
    version: 16.2/16C5032a
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.9
    path: /usr/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 19.0.0
    wanted: 19.0.0
  react:
    installed: 19.1.0
    wanted: 19.1.0
  react-native:
    installed: 0.80.1
    wanted: 0.80.1
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: true
  newArchEnabled: true

Stacktrace or Logs

none

MANDATORY Reproducer

https://snack.expo.dev/@bs3385/textinput

Screenshots and Videos

No response

Activity

  1. react-native-bot commented on Jul 23, 2025

    @react-native-bot
    Collaborator

    Warning

    Missing reproducer: We could not detect a reproducible example in your issue report. Reproducers are mandatory and we can accept only one of those as a valid reproducer:


    You can read more about about it on our website: How to report a bug.

  2. BS3385 commented on Jul 23, 2025

    @BS3385
    Author
  3. cipolleschi commented on Jul 23, 2025

    @cipolleschi
    Contributor

    Hi @BS3385 thanks for the issue.

    Have you tried disabling the new architecture in your app/build.gradle file? Just to understand if this is a New Arch specific issue or if it was like that in the Legacy architecture as well.

    Jumping from 0.73 to 0.80 is a big jump, so I'd also suggest you to go through the blogpost we published in https://reactnative.dev/blog to look for possible braking changes we announced there.

    cc. @cortinico

  4. cipolleschi commented on Jul 23, 2025

    @cipolleschi
    Contributor

    Also, the snack doesn't show the bug:

    Image
  5. cortinico commented on Jul 23, 2025

    @cortinico
    Contributor

    @BS3385 In order to triage this further we would need to isolate when is this happening.

    Specifically, in a sample project on 0.80 please try and verify if:
    a. It happens on old/new arch?
    b. It happens on target SDK 34/35/36?

    And please report back.

  6. NickGerleman commented on Jul 24, 2025

    @NickGerleman
    Contributor

    Depending on locale, https://developer.android.com/about/versions/15/behavior-changes-15#elegant-text-height is an "interesting" change that I have no idea if we are supporting correctly (I would hazard a guess that we may not, until maybe some very recent changes).

    @BS3385 what locale is your phone?

  7. BS3385 commented on Jul 24, 2025

    @BS3385
    Author

    Also, the snack doesn't show the bug:

    Image

    I’m using the new architecture.

    Are you testing with the Android 15 preview demo? I’ve noticed issues when previewing with that demo.

    Also, based on my debugging, the problem seems to be related to upgrading the targetSdkVersion to 35. I tested this with React Native 0.73.2 as well, and once targetSdkVersion was set to 35, the issue appeared on Android 15 too. However, it displays correctly on versions prior to Android 15. @cortinico @cipolleschi

  8. 14 remaining items

  9. milandexiaozhen commented on Jul 25, 2025

    @milandexiaozhen

    Solution:
    1. Download the Roboto font folder from the official Google Fonts website.
    In the static directory, choose Roboto-Regular.ttf and Roboto-Bold.ttf, then copy them to:
    android/app/src/main/assets/fonts
    https://fonts.google.com/specimen/Roboto?utm_source=chatgpt.com
    2. Run the following command:npx react-native-asset
    3. cd android && ./gradlew clean
    4. In your index.ts file, add the following code:
    if (Platform.OS === 'android') {
    const defaultInputStyle = TextInput.defaultProps.style || {};
    TextInput.defaultProps.style = [defaultInputStyle, { fontFamily: 'Roboto-Regular' }];
    }
    5.For any TextInput that uses fontWeight: 'bold',
    remove that line and replace it with:fontFamily: 'Roboto-Bold'

    This will solve the issue.

  10. xulePlus commented on Jul 25, 2025

    @xulePlus

    您能否用英语发帖(或至少包含翻译)以便我们理解您在说什么?

    我通过谷歌翻译运行了此内容:

    xulePlus > 兄弟解决了通知一声,我们小米手机15的系统也出现同样的问题 👉兄弟,我已经解决了。让我知道。我们的小米15系统也存在同样的问题。

    BS3385 > 换个系统字体,不使用MiSans字体显示正常的👉 更改系统字体,不使用MiSans字体显示正常

    xulePlus > 可以在Androidassets/fonts中导入字体库,在react-native.config.js中配置,然后在RN中使用这个 字体库就可以解决这个问题👉可以在Androidassets/fonts中导入字体库,在react-native.config.js中进行配置,然后在RN中使用这个字体库来解决这个问题。

    Image Image Image

    Recommended open source font library download address
    https://fonts.google.com/specimen/Roboto?utm_source=chatgpt.com

  11. BS3385 commented on Jul 31, 2025

    @BS3385
    Author

    Xiaomi replied that it will optimize the display issue of "MiSans" in subsequent versions

  12. alanleedev commented on Aug 1, 2025

    @alanleedev
    Contributor

    @BS3385 Thanks for the update

    Xiaomi replied that it will optimize the display issue of "MiSans" in subsequent versions

  13. MarchewkaMatthew commented on Aug 22, 2025

    @MarchewkaMatthew

    It seems that having Persian set as a phone language (and probably other languages mentioned here: https://developer.android.com/about/versions/15/behavior-changes-15#elegant-text-height ) may cause unexpected font issues. Surprisingly, even if these languages are set as a secondary language, they might still break something.

    In my case, on a Samsung S22 (Android 15) with German set as the primary language and Persian as the secondary, some texts in the app were cut off at the top (see attached screenshot).

    Issue started to appear when we changed the targetSdkVersion to 35 (we are on 0.76.9 version of react-native).

    Do you know what might be causing this, and how we can fix it?

    Image
  14. klxiaoniu commented on Aug 22, 2025

    @klxiaoniu

    For Xiaomi device running HyperOS2 Android 15, font set to MiSans, language Chinese, add these to android/app/src/main/res/values/styles.xml inside <resources> </resources> tag: (Choose parent style according to your app)

        <style name="Widget.App.TextView" parent="Widget.AppCompat.TextView">
            <item name="android:elegantTextHeight">false</item>
            <item name="android:useLocalePreferredLineHeightForMinimum">false</item>
        </style>
    
        <style name="Widget.App.EditText" parent="Widget.AppCompat.EditText">
            <item name="android:elegantTextHeight">false</item>
            <item name="android:useLocalePreferredLineHeightForMinimum">false</item>
        </style>

    And then edit your Base application theme to add these inside <style> </style> tag:

            <item name="android:textViewStyle">@style/Widget.App.TextView</item>
            <item name="editTextStyle">@style/Widget.App.EditText</item>
            <item name="android:editTextStyle">@style/Widget.App.EditText</item>

    Then recompile your app, the issue should be gone.

    If you are using expo, you can use this plugin.

    This is related to Changes introduced in Android 15, apps targeting Android 15 will apply these by default, while Xiaomi system and font developers made these features broken.😡 So we have to disable them manually.

    Ps: It's said that the bug is fixed in Xiaomi Android 16 system, but I don't have any device to test that.

  15. alanleedev commented on Sep 4, 2025

    @alanleedev
    Contributor

    @MarchewkaMatthew You should file a new issue with code to reproduce the problem.

  16. pierroo commented on Sep 29, 2025

    @pierroo

    This may also be linked to the issue of Texts being cut randomly since 0.80+, I had created an issue as well about it:
    #53666

  17. ysng007 commented on Oct 16, 2025

    @ysng007

    Xiaomi replied that it will optimize the display issue of "MiSans" in subsequent versions

    I tested it with Xiaomi Android 16 and there is no problem

  18. Super-Crab commented on Dec 5, 2025

    @Super-Crab

    @BS3385 you can try to fixed the method of "updateTextPaint" in TextLayoutManager.TextPaint use reset API,but reset has bug in HyperOS2

  19. react-native-bot commented on Jun 4, 2026

    @react-native-bot
    Collaborator

    This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

  20. added
    StaleThere has been a lack of activity on this issue and it may be closed soon.
    on Jun 4, 2026
  21. react-native-bot commented on Jun 13, 2026

    @react-native-bot
    Collaborator

    This issue was closed because it has been stalled for 7 days with no activity.

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

    Component: TextInputRelated to the TextInput component.Needs: AttentionIssues where the author has responded to feedback.Needs: ReproThis issue could be improved with a clear list of steps to reproduce the issue.Platform: AndroidAndroid applications.StaleThere has been a lack of activity on this issue and it may be closed soon.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions