在 onCreate中写:
if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.KITKAT){
Window window = getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
}
清单文件中写: android:theme="@style/ToolBarTheme"
styles中写: <style name="ToolBarTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- toolbar颜色 -->
<item name="colorPrimary">@color/colorPrimaryDark</item>
<!-- 状态栏的颜色 -->
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<!-- toolbar的主题-->
<item name="toolbarStyle">@style/ClubToolbar</item>
</style>
<style name="ClubToolbar" parent="Widget.AppCompat.Toolbar">
<!-- 设置该属性解决空白部分-->
<item name="contentInsetStart">16dp</item>
<item name="contentInsetEnd">16dp</item>
</style>
沉浸式
最新推荐文章于 2019-03-26 14:11:11 发布