最近我在 Main_Activity
:
(getWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS))
用于状态栏透明目的。一切进展顺利,但我的android导航栏也采用了透明策略。现在我只需要透明的状态栏,而不需要导航栏。
最近我在 Main_Activity
:
(getWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS))
用于状态栏透明目的。一切进展顺利,但我的android导航栏也采用了透明策略。现在我只需要透明的状态栏,而不需要导航栏。
1条答案
按热度按时间mjqavswn1#
您有两个选择要做,首先,我建议您使用一个外部库来设置状态栏样式,如statusbarutil库,它使您能够在一行中满足您的需求:
这个库不会影响导航栏。
首先确保在应用程序级gradle中实现库:
第二个选项是进行布局自定义,如本教程中所述,您可以将以下内容添加到
style.xml
:并将此样式应用于清单中的活动:
如本教程所述:
我已经准备好了android:windowdrawssystembarbackgrounds to 是的。
这是一个标志,其描述如下:
指示此窗口是否负责绘制系统栏背景的标志。如果为true且窗口不是浮动的,则系统栏将以透明背景绘制,此窗口中的相应区域将填充{@link android.r.attr#statusbarcolor}和{@link android.r.attr#navigationbarcolor}中指定的颜色。对应于{@link android.view.windowmanager.layoutparams#flag#drawssystembarbackgrounds}。
别忘了添加属性
android:fitsSystemWindows="true"
到活动布局的上根目录。