我可以只为状态栏设置FLAG_LAYOUT_NO_LIMITS吗? [英] Can I set FLAG_LAYOUT_NO_LIMITS only for status bar?
问题描述
我需要制作透明的状态栏。我正在使用 getWindow()。addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS)
,它是我想要的状态栏。但这也会影响导航栏:它变得透明,并且 getWindow()。setNavigationBarColor(Color.BLACK)
无效。
I need to make transparent status bar. I am using getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS)
and it is make status bar as I want. But it also affect navigation bar: it became transparent and getWindow().setNavigationBarColor(Color.BLACK)
do nothing.
有没有办法只使透明的状态栏而不是导航栏?
Is there way to make transparent status bar only and not navigation bar?
推荐答案
对我来说这有用
getWindow().setFlags(
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
)
styles.xml
styles.xml
<style name="TranslucentStatusBar" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowTranslucentStatus">true</item>
</style>
v21\styles.xml
v21\styles.xml
<style name="TranslucentStatusBar" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowDrawsSystemBarBackgrounds">false</item>
<item name="android:windowTranslucentStatus">true</item>
</style>
状态栏将是透明或半透明的,导航栏不会
status bar will be transparent or translucent, navigation bar won't
希望这会有所帮助!
这篇关于我可以只为状态栏设置FLAG_LAYOUT_NO_LIMITS吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!