打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Android Linearlayout 平分它的子控件
要让LinearLayout内的子控件平分需要使用布局内的一个属性 layout_weight
这个属性的意思是比重,设置多大就表示需要占据父控件的多少空间,越大占的比重越大。
如果要让子空间平分,仅仅将所有子控件的layout_weight的属性设置为1是不行的,
当子控件内的内容不一样时,会出现不平分的情况,这个时候就 要将每个子控件的layout_width设置为0dip

例子:
<LinearLayout 
              android:orientation="horizontal"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"
        >

  <EditText
          android:layout_weight="1"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
          />
    <Button
            android:layout_weight="2"
            android:text="提交"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            />
</LinearLayout>



具体可以参考官方文档
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
动态改变Android控件大小
菜鸟Android开发系列之:线性布局
Android开发自学笔记(Android Studio)—4.1布局组件
四种方案解决ScrollView嵌套ListView问题
android各种组件的监听器
Android 学习笔记一些小知识点(2013.10.9更新)
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服