Android HorizontalScrollView 或者 ScrollView 子项可滚动状态下遇到尾部显示不全问题解决

HorizontalScrollView为例

  <HorizontalScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:padding="10dp"
        android:background="@color/green">
        <LinearLayout
            android:layout_margin="10dp" 
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:background="@color/windowBackground"
            android:orientation="horizontal">
     <!-- 内容代码生成 -->

	</LinearLayout>
  </HorizontalScrollView>

1、下面是子项不足以滚动没问题
在这里插入图片描述

2、下图示意子项长度很长后 拉倒最有端 末端缺少 1 竖 灰色

在这里插入图片描述

3、修改布局去掉

android:layout_margin="10dp" 

即可

在这里插入图片描述

4、结论:HorizontalScrollView 、ScrollView 子项不要用 layout_margin 属性,在 HorizontalScrollView 、ScrollView 上面做变相处理实现对应需求,或者改用别的组件

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章