我正在设置一个简单的视图,其中仅包含一个空的RelativeLayout:
<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>
它是这样的:
有任何想法吗?
摆脱android:fitsSystemWindows="true"
来自RelativeLayout
。我不认为两者可以同时适合系统视图,并且父级始终优先于子级
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)