Android LinearLayout线性布局
2024-09-06 03:47:29
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>
最新文章
- WebForm session,cookies
- POJ2411
- 微软发布ASP.NET 5路线图
- Android优化——UI优化(三)使用ViewStub延迟加载
- jQuery理解之(一)动画与特效
- 剑指offer系列62---两个链表的公共结点
- check the manual that corresponds to your MySQL server version for the right syntax的错误解析
- BZOJ 3907: 网格( 组合数 + 高精度 )
- C# Unity游戏开发——Excel中的数据是如何到游戏中的 (三)
- java操作redis redis连接池
- OAuth及第三方登录
- 高性能队列Disruptor系列2--浅析Disruptor
- 修改MySQL数据库密码
- 02 浅析Spring的AOP(面向切面编程)
- 理解 Linux 中 `ls` 的输出
- springboot秒杀课程学习整理1-5
- 2012年NOIP普及组 摆花
- 【GMT43智能液晶模块】例程十三:FATFS实验——文件操作
- vmware自定义网段
- powerdesidgner1
热门文章
- 2017.2.12 开涛shiro教程-第七章-与Web集成
- 服务器性能之CPU
- 又一次遇到Data truncation: Data too longData truncation: Data too long问题
- tcpdump命令使用详解
- zepto jquery和zepto的区别?
- [ACM] HDU 5024 Wang Xifeng&;#39;s Little Plot (构造,枚举)
- ie6中 object doesn’t support this property or method
- Android 属性动画框架 ObjectAnimator、ValueAnimator ,这一篇就够了
- items"; does not support runtime expression
- HTML5开发移动web应用——SAP UI5篇(8)