AndroidUtilCode icon indicating copy to clipboard operation
AndroidUtilCode copied to clipboard

本库在android11上使状态栏亮色模式失效(不进行任何方法调用)

Open KittenBall opened this issue 2 years ago • 0 comments

Android11 引入此库后,会使android11的状态栏亮色模式仅生效一次

  • AndroidUtilCode 的版本:1.31.0
  • 出现 Bug 的设备型号:Pixel XL Api 3 (AndroidStudio Emulator)
  • 设备的 Android 版本:api 30

使用AndroidStudio创建任意项目,build.gradle大致如下

android {
    compileSdk 32

    defaultConfig {
        applicationId "xxx"
        minSdk 21
        targetSdk 32
        versionCode 1
        versionName "1.0"
    }
}

buildFeatures {
        viewBinding = true
}

dependencies {

    implementation 'androidx.core:core-ktx:1.7.0'
    implementation 'androidx.appcompat:appcompat:1.4.2'
    implementation 'androidx.activity:activity-ktx:1.4.0'
    implementation 'com.google.android.material:material:1.6.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    implementation 'com.blankj:utilcodex:1.31.0'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}

MainActivity相当简单,是一个空白页,onCreate内使用android11官方推荐的亮色模式 activity_main

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity"/>
class MainActivity : AppCompatActivity() {

    private lateinit var binding: ActivityMainBinding

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = ActivityMainBinding.inflate(layoutInflater)
        setContentView(binding.root)
        ViewCompat.getWindowInsetsController(window.decorView)?.isAppearanceLightStatusBars = true
    }
}

启动后正常显示,符合预期,此时返回桌面,再次打开,状态栏就是暗色模式,没有使用任何UtilCode的代码。去掉此库后正常。 GIF 2022-6-15 9-28-30

KittenBall avatar Jun 15 '22 01:06 KittenBall