简体   繁体   English

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

[英]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.在使用 Android 7 的设备上从 androidx 实现生物特征库后,我的应用程序出现问题。在我的主应用程序中更改手机的可访问性设置中的字体大小和应用程序中的文本大小时,问题开始了. 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.在查明问题后,我创建了一个带有单个“hello world”活动的虚拟应用程序,我发现即使仅通过在 app.gradle 中声明库的依赖关系,也会重现该错误。 This is the activity's xml:这是活动的 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:这是 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.值得一提的是,如果我删除了 androidx 生物识别的依赖项,字体缩放工作没有任何问题,但是一旦我添加了依赖项,更改字体大小对应用程序中的字体大小没有影响。

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.我已经在带有 Android 7 的 HTC 10 和带有 API 24 的模拟器上进行了测试。另一件值得一提的事情是字体缩放适用于 Android9 和 1087846DZ9。

Is there something I'm missing?有什么我想念的吗?

Thank you.谢谢你。

It's caused by https://issuetracker.google.com/issues/140607881它是由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"根据错误:“API 26 之前的所有版本都受到影响,Android 8.0 是第一个可以使用 app compat 1.1.0 全局更改字体大小的版本”

"Fixed in latest AppCompat 1.2.0-alpha02" “在最新的 AppCompat 1.2.0-alpha02 中修复”

I tested the latest 1.2.0-beta01 and the fix works.我测试了最新的 1.2.0-beta01 并且修复工作。 Here are all the versions of appcomat https://developer.android.com/jetpack/androidx/releases/appcompat .这里是 appcomat https://developer.android.com/jetpack/androidx/releases/appcompat的所有版本。

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

相关问题 使用生物识别 androidx 库时崩溃 - Crash using biometric androidx library selectedItemId 在 androidx.navigation:navigation 库更新后不再工作 - selectedItemId doesn't work anymore after androidx.navigation:navigation library update Android将生物识别技术更新为1.0.0-alpha04后,Android崩溃了 - Android crashed after updating androidx biometric to 1.0.0-alpha04 AndroidX首选项库DropDownPreferences在API &lt;24上不起作用 - AndroidX Preference library DropDownPreferences doesn't work on API < 24 使用生物识别 androidX 库 1.1.0 崩溃 - Crash using biometric androidX library 1.1.0 androidx迁移后,Android Studio应用程序未安装在模拟器上 - Android Studio app doesn't install on emulator after androidx migration 在 Android 中使用 androidx Biometric API 进行人脸认证 - Face Authentication using androidx Biometric API in Android 具有自定义分辨率的模拟器无法使用Android自动缩放功能 - Android auto-scaling doesn't work on emulator with custom resolution Androidx 导航视图 - `setNavigationItemSelectedListener` 不起作用 - Androidx Navigation View - `setNavigationItemSelectedListener` Doesn't Work ImageView缩放不起作用 - ImageView scaling doesn't work
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM