<relativelayout xmlns:tools=“http://schemas.android.com/tools”
xmlns:android=“http://schemas.android.com/apk/res/android”
android:id=“@+id/root_relativelayout”
android:layout_width=“匹配父级”
android:layout_height=“匹配父级”
android:fitsSystemWindows=“真”
android:cliptopadding=“true”>
<相对布局
android:layout_width=“匹配父级”
android:layout_height=“包装内容”
android:layout_AlignParentBottom=“真”
android:orientation=“水平”>
</relativelayout>
</relativelayout>
< /代码>
内部relativelayout保持在其位置,就好像导航栏仍然存在一样,即使我在其父级relativelayout上调用了requestlayout(),它也不会落到屏幕的底部。
正如你在照片中看到的,底部有一个山墙。

我找到了解决这个问题的方法,但它也会导致另一个问题。
我想到的解决方案是将android:fitssystemwindows设置为false而不是true。
但这会导致一个问题,即我的活动的对齐顶部视图位于状态栏的后面,我认为唯一的解决方案是将顶部填充设置为状态栏的高度。
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
View decorView = getWindow().getDecorView();
decorView.setSystemUiVisibility(uiOptions);
}
RootRelativeLayout.requestLayout();
我的活动代码
<RelativeLayout xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/root_relativelayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:clipToPadding="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal">
</RelativeLayout>
</RelativeLayout>
内部relativelayout保持在它的位置,就好像导航栏仍然存在,并且不会下降到屏幕的底部,即使我在它的父relativelayout上调用了requestlayout()。
正如你在照片中看到的,底部有一个山墙。

我找到了这个问题的解决方案,但它也引起了另一个问题。
我想到的解决方案是设置android:fitsSystemWindows为假而不是真。
但这会导致一个问题,即我的活动的对齐顶部视图位于状态栏的后面,我认为唯一的解决方案是将顶部填充设置为状态栏的高度。