Android 嵌套滚动视图中的子视图未覆盖屏幕的整个高度

Android 嵌套滚动视图中的子视图未覆盖屏幕的整个高度,android,android-scrollview,android-relativelayout,android-nestedscrollview,Android,Android Scrollview,Android Relativelayout,Android Nestedscrollview,我正在片段中使用NestedScrollView。在我的xml里有一个相对的窗口,但它并没有覆盖整个屏幕的高度 以下是我的密码- <?xml version="1.0" encoding="utf-8"?> <android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" and

我正在片段中使用NestedScrollView。在我的xml里有一个相对的窗口,但它并没有覆盖整个屏幕的高度

以下是我的密码-

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:fitsSystemWindows="true"
android:background="@color/black"
android:layout_width="match_parent"
android:layout_height="match_parent">

<RelativeLayout
    android:background="@color/red_error_color"
    android:layout_width="match_parent"
    android:layout_height="match_parent">


</RelativeLayout>
</android.support.v4.widget.NestedScrollView>

运行代码时,只有黑色背景可见,而不是红色,因为我的子视图背景是红色的


提前感谢

尝试在nestedscrollview中添加这行代码

android:fillViewport="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
删除:

android:fitsSystemWindows="true"

我想在更一般的情况下,android:fillViewport=“true”就足够了。(为我工作)