FrameLayout与NestedScrollView的高度不匹配

lea*_*ner 11 android android-layout nestedscrollview android-framelayout

我在NestedScrollView中有一个FrameLayout,如

<android.support.v4.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="#000000">
Run Code Online (Sandbox Code Playgroud)

但是FrameLayout没有填充NestedScrollView的高度.我该如何解决这个问题?

Sye*_*med 44

检查此解决方案
使用fillViewport="true" 此属性可使滚动视图的子项扩展到ScrollView的高度(如果需要).当孩子比ScrollView高时,该属性无效.

 <android.support.v4.widget.NestedScrollView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
      android:fillViewport="true"
            app:layout_behavior="@string/appbar_scrolling_view_behavior">
Run Code Online (Sandbox Code Playgroud)