出现的问题复现:
ScrollView下包含一个LinearLayout,LinearLayout中包含很多个子view,最后一个子
view不管是不是滑到了底部都显示不全
布局如下:
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="vertical">
出现的原因:
在LinearLayout中设置了layout_margin=“10dp”,layout_marginTop=”10dp”会导致ScrollView在开始的时候会往下移动10dp
解决方法:
不要在LinearLayout中设置layout_marginTop属性即可,移动到ScrollView中或者使用padding
本文介绍了在ScrollView中,LinearLayout的子view出现显示不全的问题,问题复现为最后一个子view无法完全展示。原因在于LinearLayout设置了layout_margin和layout_marginTop,导致ScrollView在初始位置下移。解决方法是避免在LinearLayout中设置layout_marginTop,可以将其移动到ScrollView中或使用padding来替代。
2493

被折叠的 条评论
为什么被折叠?



