我正在设置一个简单的视图,其中只包含一个空的RelativeLayout:
这将产生预期的效果: 然而,当我尝试添加一个子元素时,我无法做到同样的事情。XML看起来像这样:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:clipToPadding="false"
android:background="@color/red"/>
使用这个主题:
<style name="FullscreenTheme" parent="BaseTheme">
<item name="android:textColorSecondary">@android:color/white</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:navigationBarColor">@android:color/transparent</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
</style>
在onCreate方法中添加以下内容:
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
}
这将产生预期的效果: 然而,当我尝试添加一个子元素时,我无法做到同样的事情。XML看起来像这样:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:clipToPadding="false"
android:background="@color/red">
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/bit_teal"
android:fitsSystemWindows="true"
android:clipToPadding="false"/>
</RelativeLayout>
以下是展示效果:
有什么想法吗?