简体   繁体   中英

Font scaling doesn't work after implementing androidx biometric library on Android 7

I'm having issues in my app after implementing the biometric library from androidx on a device with Android 7. The issues started in my main app when changing the font size in the phone's accessibility settings and the text size in the app didn't change. After pinpointing the problem, I have created a dummy app with a single "hello world" activity and I have found out that even only by declaring the library's dependency in app.gradle reproduces the bug. This is the activity's xml:

<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World!"
        android:textSize="16sp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

And this is the build.gradle:

apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 28


    defaultConfig {
        applicationId "com.example.fontscaletestapplication"
        minSdkVersion 23
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

}

dependencies {
    implementation "androidx.biometric:biometric:1.0.1"
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'androidx.core:core-ktx:1.0.2'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}

Worth mentioning is that if I remove the dependency for androidx biometric, the font scaling works without any problems, but as soon as I add the dependency, changing the font size has no impact on the size of the font in the app.

From what I noticed in the main app, I think it has something to do with the application context and the application resources, but I can't figure out what the problem is. I have tested on a HTC 10 with Android 7 and on emulator with API 24. Another thing worth mentioning is that the font scaling works on Android 9 and 10.

Is there something I'm missing?

Thank you.

It's caused by https://issuetracker.google.com/issues/140607881

According to the bug: "All version before API 26 are affected, Android 8.0 is the first version where is possible to change font size globally with app compat 1.1.0"

"Fixed in latest AppCompat 1.2.0-alpha02"

I tested the latest 1.2.0-beta01 and the fix works. Here are all the versions of appcomat https://developer.android.com/jetpack/androidx/releases/appcompat .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM