解决NestedScrollView 布局不能撑满屏幕 的问题

2023-08-01  本文已影响0人  雨田Android开发

最近使用 NestedScrollView 嵌套使其布局超出屏幕时滑动; 想让最后一个子布局位于屏幕最底方;

各种方法都不行,后来发现NestedScrollView 的 子布局不能撑满整个屏幕,而是包裹内容,按照wrap_content来计算,哪怕写的 match_parent 也没用;

解决办法:

添加属性:

android:fillViewport="true"  
<android.support.v4.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true"
        android:overScrollMode="never">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            .....

        </LinearLayout>
</android.support.v4.widget.NestedScrollView>
上一篇 下一篇

猜你喜欢

热点阅读