<LinearLayout        android:layout_width="match_parent"        android:layout_height="wrap_content"              android:layout_centerHorizontal="true"              android:gravity="center_horizontal"        android:layout_below="@+id/linearLayout4"        android:weightSum="2"        android:layout_marginTop="40dp" >        <Button            android:id="@+id/btn_regist"      android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:layout_weight="0.5"            android:text="@string/regist" />        <Button            android:id="@+id/btn_login"              android:layout_width="wrap_content"              android:layout_weight="0.5"            android:layout_height="wrap_content"            android:layout_marginLeft="50dp"            android:text="@string/login" />    </LinearLayout>


父容器 声明android:weightSum

子对象 声明android:layout_weight

子对象会自适应父容器大小。如下效果图,注意底部button的尺寸

竖屏时的效果

android:layout_weight 使用_第1张图片


横屏效果

android:layout_weight 使用_第2张图片


更多相关文章

  1. FregClient进程,创建一个BpFregService类型的代理对象
  2. android XMl 解析神奇xstream 三: 把复杂对象转换成 xml
  3. Android中一个Activity调用另一个Activity — Intent对象的使用
  4. android中怎样声明操作通话记录的权利
  5. android页面间传递对象
  6. Android O版本Call对象解析
  7. Android学习笔记4之容器
  8. FregServer进程,获取ServiceManager代理对象
  9. 2011.07.19——— android intent 传递list或者对象

随机推荐

  1. 如何监控android的流量信息
  2. Android(安卓)程序适应多种多分辨率
  3. 史上最全的Android面试题集锦
  4. Android(安卓)getDimensionPixelSize, 代
  5. Android(安卓)内存管理
  6. 《Android(安卓)开发工程师面试指南》
  7. android的图形系统
  8. android应用安全——通信安全(android htt
  9. 在Android上调用OpenCV 2.4.10库函数
  10. [置顶] android 自定义控件