效果如图
步骤
1. 在style.xml文件中添加如下代码
1
2
3
4
5
6
7
8
9
10
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- 其他设置 -->
<!-- 隐藏标题栏和设置状态栏透明 -->
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
</style>
2. 在xml中删除属性
1
android:fitsSystemWindows="true"