繁体   English   中英

在 Android 7 上实现 androidx 生物识别库后,字体缩放不起作用

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

在使用 Android 7 的设备上从 androidx 实现生物特征库后,我的应用程序出现问题。在我的主应用程序中更改手机的可访问性设置中的字体大小和应用程序中的文本大小时,问题开始了. 在查明问题后,我创建了一个带有单个“hello world”活动的虚拟应用程序,我发现即使仅通过在 app.gradle 中声明库的依赖关系,也会重现该错误。 这是活动的 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>

这是 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'
}

值得一提的是,如果我删除了 androidx 生物识别的依赖项,字体缩放工作没有任何问题,但是一旦我添加了依赖项,更改字体大小对应用程序中的字体大小没有影响。

从我在主应用程序中注意到的情况来看,我认为它与应用程序上下文和应用程序资源有关,但我无法弄清楚问题所在。 我已经在带有 Android 7 的 HTC 10 和带有 API 24 的模拟器上进行了测试。另一件值得一提的事情是字体缩放适用于 Android9 和 1087846DZ9。

有什么我想念的吗?

谢谢你。

它是由https://issuetracker.google.com/issues/140607881引起的

根据错误:“API 26 之前的所有版本都受到影响,Android 8.0 是第一个可以使用 app compat 1.1.0 全局更改字体大小的版本”

“在最新的 AppCompat 1.2.0-alpha02 中修复”

我测试了最新的 1.2.0-beta01 并且修复工作。 这里是 appcomat https://developer.android.com/jetpack/androidx/releases/appcompat的所有版本。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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