浅谈安卓布局之线性布局
来源:互联网 发布:手机吉他软件模拟 编辑:程序博客网 时间:2024/06/05 13:24
一、线性布局 linearlayout
线性布局是按照水平或垂直的顺序将子元素(可以是控件或布局)依次按照顺序排列,
每一个元素都位于前面一个元素之后,若不指定默认水平。
1 android:orientation 确定线性布局的方向
vertical:表示垂直方向
horizontal:表示水平布局
2 android:layout_width 组件布局的宽度(也可自己定义大小)
macth_parent:填满parent的宽度(充满父控件)
wrap_content:组件宽度会依照内容大小而调整
3 android:layout_height 组件布局的高度
macth_parent:填满parent的高度(充满父控件)
wrap_content:组件高度会依照内容大小而调整
4 android:background:改变控件的颜色或在控件中添加图片,后面跟
#(xxxxxx)其中x代表字母或数字表示不同的颜色。
5 android:layout_margin:指定这个view距离上下左右的额外距离
其中还可指定某一方向上的距离:但是需要指定单位,
android:layout_marginLeft(左)
android:layout_marginRight(右)
android:layout_marginBottom(下)
android:layout_marginTop(上)
6 Layout_gravity:操控控件位于布局的什么位置。
有left(左)、right(右)、top(上)、bottom(下)、center_vertical(位于垂直的中部)
center_horizontal(位于水平的中部)、center(中部)。
注:当外部布局为垂直时,只能在水平方向上操作,当外部布局为水平时,
只能在垂直方向上操作。可以连写:android:layout_gravity="bottom|left"
Gravity:操控控件内部文字位于控件的位置。
有left(左)、right(右)、top(上)、bottom(下)、center_vertical(位于垂直的中部)
center_horizontal(位于水平的中部)、center(中部)。
代码:
<Button
android:layout_gravity="bottom"
android:layout_width="100dp"
android:layout_height="100dp"
android:text="btn1"/>
<Button
android:gravity="bottom"
android:layout_width="100dp"
android:layout_height="100dp"
android:text="btn2"/>
效果图:
- 浅谈安卓布局之线性布局
- 安卓布局--线性布局
- 安卓之基本线性布局
- 安卓线性布局案例之计算器
- 安卓布局之线性布局(Linearlayout)
- 安卓六大布局之 线性布局(LinearLayout)
- 安卓布局 - 线性布局(LinearLayout)
- 安卓布局:线性布局(Linearlayout)和相对布局(RelativeLayout)
- 安卓开发06:布局-线性布局 LinearLayout
- 安卓开发06:布局-线性布局 LinearLayout
- 安卓布局基础笔记(LinearLayout -- 线性布局 )
- 安卓XML布局,线性布局常用属性总结~
- 安卓常用布局(线性、相对、帧、表格布局)
- 安卓入门【linearlayout线性布局,Tablelayput表格布局】
- 安卓布局之帧布局
- 安卓布局之FrameLayout布局
- 安卓布局之表格布局(TableLayout)
- android布局之线性布局
- Android带文字的ImageButton实现
- 15.2.1 字符串的连接
- JAVA基础--I/O
- 删除github上的文件
- Python 使用SMTP 实现发邮件功能
- 浅谈安卓布局之线性布局
- Layout布局之帧布局
- hihihi
- 罪犯转移 用滑动窗口做,一次AC
- 新学C++的时间处理
- 15.1.3 字符串的比较
- java多线程学习
- 配置型工厂设计模式
- 欢迎使用CSDN-markdown编辑器