我在AppBarLayout
下有一个NestedScrollView
,它只有一个子控件-LinearLayout
。它们都没有顶部填充和边距,但是在NestedScrollView
的顶部仍然留有一些空间(根据背景颜色可以看出)。如何去除它?
我尝试在NestedScrollView
中设置android:fillViewport="true"
,但没有效果。
更新:这个空间与clipNoPadding标志交互,但将所有填充设置为0也无济于事。
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.v4.widget.NestedScrollView
android:id="@+id/scroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:background="@color/colorAccent"
android:fillViewport="true"
app:layout_behavior="android.support.design.widget.AppBarLayout$ScrollingViewBehavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorPrimary"
android:orientation="vertical">
<Button
android:id="@+id/button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button" />
// and some more buttons, just to fill the space
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:fitsSystemWindows="true"
android:background="@color/colorTransparent">
// I omit some code, as not-belonging to the question
</android.support.design.widget.AppBarLayout>
</android.support.design.widget.CoordinatorLayout>
fitsSystemWindows
属性会发生什么? - Ben P.