簡體   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