NestedScrollView 中嵌套 LinearLayout,使用layout_weight不生效

1.現象

NestedScrollView 中嵌套 LinearLayout,使用layout_weight不能生效

2 解決方案

NestedScrollView繼承於ScrollView,故添加屬性android:fillViewport="true"即可

<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    ...
    android:fillViewport="true">
    ...
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">
        ...
        <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1">
    ...
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章