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 上面做變相處理實現對應需求,或者改用別的組件

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