Android ScrollView が画面いっぱいに表示されていない場合、デフォルトで画面全体に表示されます。

<androidx.core.widget.NestedScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/bg_color"
        android:orientation="vertical">
            
        ....一大堆控件....

    </LinearLayout>
</androidx.core.widget.NestedScrollView>

上記は画面いっぱいに設定されていますが、実行による効果はそうではありません。

fillViewport 属性を追加

<androidx.core.widget.NestedScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/bg_color"
        android:orientation="vertical">
            
        ....一大堆控件....

    </LinearLayout>
</androidx.core.widget.NestedScrollView>

NestedScrollView と ScrollView は同じです。

おすすめ

転載: blog.csdn.net/fromVillageCoolBoy/article/details/131719625