我的应用程序使用一个活动与ViewPager交换应用程序页面的片段。每个其他片段都有效,但出于某种原因,其中一个片段,我的设置片段,并没有。下图说明了这一点。红色区域是不需要的边距。蓝色区域是在主活动布局中定义的工具栏 - 它始终存在。绿色区域是主要的ViewPager,也在主要活动布局中定义:
这就是MainActivity布局的样子:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Settings"
android:id="@+id/textView2"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:paddingTop="10dp" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Log Out"
android:id="@+id/logout"
android:layout_below="@+id/textView2"
android:layout_centerHorizontal="true"
android:paddingTop="10dp" />
</RelativeLayout>
这就是Settings片段的样子:
android:fitsSystemWindows="true"
如何修复此不必要的保证金?如果我从主布局中删除sourceComments: true
,那么每个其他页面都会在标签栏上绘制通知栏,这是我不想要的。
答案 0 :(得分:9)
不确定如何,但我能够通过删除我拥有的android:fitsSystemWindows="true"
来修复它。删除过去打破了一切。现在它修好了。