NestedScrollView嵌套LinearLayout布局不能撑满全屏的问题

当ScrollView里的元素想填满ScrollView时,使用"fill_parent"或者"match_parent"是不管用的,必需为ScrollView设置:android:fillViewport="true"。  

   当ScrollView没有fillViewport=“true”时, 里面的元素(比如LinearLayout)会按照wrap_content来计算(不论它是否设了"fill_parent"或者"match_parent"),而如果LinearLayout的元素设置了fill_parent,那么也是不管用的,因为LinearLayout依赖里面的元素,而里面的元素又依赖LinearLayout,这样自相矛盾.所以里面元素设置了fill_parent,也会当做wrap_content来计算.

猜你喜欢

转载自blog.csdn.net/guodashen007/article/details/112387608