本文主要是介绍android:navigationBarColor失效,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
android:navigationBarColor失效。
上结论,是项目引入了setupdesign设计,GlifLayout相关联的自定义布局overrride了NavigationBar主题,需要用setupdesign自定义的属性来设置颜色。
<item name="android:navigationBarColor">@color/black</item>
<item name="sucSystemNavBarBackgroundColor">@color/red</item> <!- actual work color -->
网上介绍了大量主题设置navigationbarColor的方式,甚至java代码控制的方式。
但一一试过均无效,断点Window.setNavigationBarColor() API,发现是setupdesign子模块里边SystemNavBarMixin重载了系统的navigation主题设置。
setNavigationBarColor:3822, PhoneWindow (com.android.internal.policy)
setSystemNavBarBackground:117, SystemNavBarMixin (com.google.android.setupcompat.template)
applyPartnerCustomizations:82, SystemNavBarMixin (com.google.android.setupcompat.template)
init:109, PartnerCustomizationLayout (com.google.android.setupcompat)
<init>:76, PartnerCustomizationLayout (com.google.android.setupcompat)
<init>:97, GlifLayout (com.google.android.setupdesign)
newInstance0:-1, Constructor (java.lang.reflect)
newInstance:343, Constructor (java.lang.reflect)
createView:858, LayoutInflater (android.view)
createViewFromTag:1010, LayoutInflater (android.view)
createViewFromTag:965, LayoutInflater (android.view)
inflate:663, LayoutInflater (android.view)
inflate:538, LayoutInflater (android.view)
inflate:485, LayoutInflater (android.view)
setContentView:696, AppCompatDelegateImpl (androidx.appcompat.app)
setContentView:170, AppCompatActivity (androidx.appcompat.app)
onCreate:56, MainActivity2 (com.test.testd)
performCreate:8013, Activity (android.app)
performCreate:7993, Activity (android.app)
callActivityOnCreate:1329, Instrumentation (android.app)
performLaunchActivity:3561, ActivityThread (android.app)
handleLaunchActivity:3745, ActivityThread (android.app)
execute:102, LaunchActivityItem (android.app.servertransaction)
executeCallbacks:135, TransactionExecutor (android.app.servertransaction)
execute:95, TransactionExecutor (android.app.servertransaction)
handleMessage:2180, ActivityThread$H (android.app)
dispatchMessage:106, Handler (android.os)
loopOnce:201, Looper (android.os)
loop:288, Looper (android.os)
main:7746, ActivityThread (android.app)
invoke:-1, Method (java.lang.reflect)
run:548, RuntimeInit$MethodAndArgsCaller (com.android.internal.os)
main:974, ZygoteInit (com.android.internal.os)
从代码看是sucSystemNavBarBackgroundColor来控制navgationbar颜色。
从上截图可以看到,setupdesign自定义baseTheme里边设置了颜色为black,如果将android:navigationBarColor颜色改为黑色意外的值,会发现根本不生效。
因为应用了GlifLayout布局的界面 window navigationBarColor不取决于android:navigationBarColor, 其次其色值不于取决定性的sucSystemNavBarBackgroundColor色值不一致。
这篇关于android:navigationBarColor失效的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!