当前位置:首页 > 笔记 > 正文内容

ScrollView layout_margin不生效

jsc4年前 (2022-03-18)笔记2408

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


扫描二维码推送至手机访问。

版权声明:本文由微小站发布,如需转载请注明出处。

本文链接:https://www.jsc0.com/post/209.html

标签: 滑动刷新
分享给朋友:

“ScrollView layout_margin不生效” 的相关文章

Bitmap too large to be uploaded into a texture

从手机相册里面显示图片,但是发现有的图片能显示有的图片不能显示,路径都是对的,程序也没提示任何错误。后来通过看日志发现error message: Bitmap too large to be uploaded into a texture (4208x3120, max=4096x409...

Android笔记:百度地图与高德地图坐标转换问题

安卓项目使用了百度地图的定位SDK,web端使用的也是百度地图, 后来发现界面显示百度地图不如高德效果好,web改用高德地图,原本的百度地图坐标是可以直接使用的,由于高德和百度地图的坐标系不一致 要如何转换呢。补充了下坐标系知识后发现高德使用的坐标系是“gcj02”也就是大家所说的“火星坐标”,百度...

百度地图被外部调用的问题

选择手机里安装的外部地图应用,在外部地图应用里显示商户的位置。Uri mUri = Uri.parse("geo:39.922840,116.3543240?q=39.922840,116.3543240(北京市西城区阜外大街2号万通大厦)");Intent mIntent =...

TabLayout getCustomView为空的问题

今天用Tablayout——ViewPage出现getCustomView为空的问题通过源码发现,ViewPage的adapter更新会吧TabLayout  的customViewc置空。这个时候自动调用OnTabSelectedListener的onTabSelected方法去获取Cu...

RecyclerView点击最后一个无效

RecyclerView设置的OnItemClick点击最后一个无效,在点击最后一个无效后在部分手机上点击其他item会触发最后一个view的onclick事件,有的手机始终无反应。是因为popwindow里RecyclerView宽度设置为match_parent的原因改为wrap_content...

Manifest merger failed with multiple errors, see logs

在android开发的时候,有时候会遇到这样的问题Error:Executionfailedfortask':test:processDebugManifest'.>Manifestmergerfailedwithmultipleerrors,seelogs但是要命的是,除了这...