等等,这不是重复的
类似的问题已被问到here https://stackoverflow.com/questions/38025865/android-fully-transparent-status-bar-with-non-transparent-navigation-bar,但没有解决暗文本状态栏的问题。
我想做的事
我想实现三件事同时:
- 透明状态栏(不是隐藏它!)
- 深色文本状态栏
- 不透明(或黑色)导航栏(不会让活动内容在其下方膨胀)
我尝试过的
解决方案
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
只能实现1和3;
解决方案here https://stackoverflow.com/a/29311321/7870874只能实现1和2;
以及解决方案here https://stackoverflow.com/a/33509124/7870874只能达到2和3....
问题
那么有没有办法同时实现1、2、3呢?
Inside styles.xml
:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
...
<item name="android:navigationBarColor">@android:color/black</item>
<item name="android:statusBarColor">@android:color/transparent</item>
</style>
活动中的onCreate()
:
override fun onCreate(savedInstanceState: Bundle?) {
window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
}
会导致这样的结果:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)