首页 > 笔记 > 正文

ScrollView layout_margin不生效

2022-03-18 笔记 1112 ℃ 0 评论

Android LineaerLayout中layout_margin失效不起作用的解决方法:


<LinearLayout  

    android:id="@+id/main"  

    android:layout_width="fill_parent"  

    android:layout_height="wrap_content"  

    android:layout_margin="20dp"  

    android:orientation="vertical">  

上面这种做法在某些Android版本放到scrollview或者RelativeLayou里面的话,layout_margin会失效,不起作用!


网上没找到相关解决方案,只能自己摸索,设置各种属性,最后终于解决:


在属性里面加入android:layout_gravity="top",问题就解决了,我觉得这个是android的一个bug。



 转载地址 http://www.linuxidc.com/Linux/2012-07/65213.htm



  Ps:  上面的代码 android:layout_gravity="top"  我是加在 <ScrollView> <LinearLayout  这里面>


------------------------------------------------------------------------------------------------------------


下面的是另一种方式 android:layout_weight=”1”  (这个好像是加载ScrollView属性中,)



<ScrollView android:fillViewport="true"

    android:layout_height="wrap_content"

    android:layout_width="fill_parent"

    android:layout_weight="1">


 转载地址  http://dev.10086.cn/cmdn/bbs/thread-21816-1-1.html


猜你喜欢

日历
«    2024年3月    »
123
45678910
11121314151617
18192021222324
25262728293031
标签列表
最近发表
友情链接