LinearLayout是线性布局控件:要么横向排布,要么竖向排布

决定性属性:必须有的!

android:orientation:vertical (垂直方向) 、horizontal(水平方向)

常用属性:

android:gravity------------设置的是控件自身上面的内容位置

android:layout_gravity-----设置控件本身相对于父控件的显示位置

android:layout_weight----- 给控件分配剩余空间


竖向排布实例:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" > <Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="按钮1"
/> <Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="按钮2"
/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="按钮3"
/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="按钮4"
/>
</LinearLayout>

横向排布实例:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" > <Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="按钮1"
/> <Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="按钮2"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="按钮3"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="按钮4"
/>
</LinearLayout>

嵌套线性布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" > <LinearLayout >
..
</LinearLayout> <LinearLayout>
..
</LinearLayout> </LinearLayout>

最新文章

  1. WebForm session,cookies
  2. POJ2411
  3. 微软发布ASP.NET 5路线图
  4. Android优化——UI优化(三)使用ViewStub延迟加载
  5. jQuery理解之(一)动画与特效
  6. 剑指offer系列62---两个链表的公共结点
  7. check the manual that corresponds to your MySQL server version for the right syntax的错误解析
  8. BZOJ 3907: 网格( 组合数 + 高精度 )
  9. C# Unity游戏开发——Excel中的数据是如何到游戏中的 (三)
  10. java操作redis redis连接池
  11. OAuth及第三方登录
  12. 高性能队列Disruptor系列2--浅析Disruptor
  13. 修改MySQL数据库密码
  14. 02 浅析Spring的AOP(面向切面编程)
  15. 理解 Linux 中 `ls` 的输出
  16. springboot秒杀课程学习整理1-5
  17. 2012年NOIP普及组 摆花
  18. 【GMT43智能液晶模块】例程十三:FATFS实验——文件操作
  19. vmware自定义网段
  20. powerdesidgner1

热门文章

  1. 2017.2.12 开涛shiro教程-第七章-与Web集成
  2. 服务器性能之CPU
  3. 又一次遇到Data truncation: Data too longData truncation: Data too long问题
  4. tcpdump命令使用详解
  5. zepto jquery和zepto的区别?
  6. [ACM] HDU 5024 Wang Xifeng&amp;#39;s Little Plot (构造,枚举)
  7. ie6中 object doesn’t support this property or method
  8. Android 属性动画框架 ObjectAnimator、ValueAnimator ,这一篇就够了
  9. items&quot; does not support runtime expression
  10. HTML5开发移动web应用——SAP UI5篇(8)