学习Layout总结
来源:互联网 发布:2011年网络春晚 编辑:程序博客网 时间:2024/05/21 00:49
学习Layout总结
一、RelativeLayout(相对布局)
相对布局有两种,一种是相对容器而言,另一种是相对控件而言。
*下面是对控件的一种
<ImageView android:layout_width="100dp" android:layout_height="100dp" app:srcCompat="@drawable/smile1" android:id="@+id/imageView" android:layout_centerInParent="true"/><ImageView android:layout_width="50dp" android:layout_height="50dp" app:srcCompat="@drawable/rabbit4" android:layout_below="@+id/imageView" android:layout_alignLeft="@+id/imageView2" android:layout_alignStart="@+id/imageView2" android:layout_marginTop="24dp" android:id="@+id/imageView3" /><ImageView android:layout_width="50dp" android:layout_height="50dp" app:srcCompat="@drawable/rabbit2" android:layout_alignTop="@+id/imageView4" android:layout_toRightOf="@+id/imageView" android:layout_toEndOf="@+id/imageView" android:layout_marginLeft="33dp" android:layout_marginStart="33dp" android:id="@+id/imageView5" /><ImageView android:layout_width="50dp" android:layout_height="50dp" app:srcCompat="@drawable/rabbit1" android:id="@+id/imageView4" android:layout_centerVertical="true" android:layout_toLeftOf="@+id/imageView" android:layout_toStartOf="@+id/imageView" android:layout_marginRight="41dp" android:layout_marginEnd="41dp" /><ImageView android:layout_width="50dp" android:layout_height="50dp" app:srcCompat="@drawable/rabbit3" android:id="@+id/imageView2" android:layout_marginBottom="25dp" android:layout_above="@+id/imageView" android:layout_alignLeft="@+id/imageView" android:layout_alignStart="@+id/imageView" android:layout_marginLeft="13dp" android:layout_marginStart="13dp" />
二、LinearLayout(线性布局)
*在UI开发中,线性布局默认为水平显示,如果想要设置垂直,用属性orientation;
*weight表示权重
*控件布局中对齐方式用layout_gravity,文字在布局中对齐方式用gravity
<EditText android:layout_width="match_parent" android:layout_height="match_parent" android:background="#000000" android:layout_weight="1" android:layout_marginTop="10dp"/><EditText android:layout_width="match_parent" android:layout_height="match_parent" android:background="#ababab" android:layout_weight="1" android:layout_marginTop="10dp"/><EditText android:layout_width="match_parent" android:layout_height="match_parent" android:background="#0000ff" android:layout_weight="1" android:layout_marginTop="10dp"/><EditText android:layout_width="match_parent" android:layout_height="match_parent" android:background="#00ff00" android:layout_weight="1" android:layout_marginTop="10dp"/><EditText android:layout_width="match_parent" android:layout_height="match_parent" android:background="#ff0000" android:layout_weight="1" android:layout_marginTop="10dp"/>
三、TableLayout(表格布局)
*每一行用TableRow
<TableRow><EditText android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Account:"/><TextView android:layout_width="match_parent" android:layout_height="match_parent" android:hint="Input your account" android:gravity="" android:layout_weight="1"/></TableRow> <TableRow > <EditText android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Password:"/> <TextView android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1"/></TableRow><TableRow> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Login" android:layout_weight="1" android:id="@+id/button" /></TableRow>
四、GridLayout(网格布局)
五、FrameLayout(帧布局)
*帧布局在局面上是一帧一帧显示的;
*帧布局在子控件默认是左上角对齐;
<Button android:text="Button1" android:layout_width="100dp" android:layout_height="100dp" android:id="@+id/button" /><Button android:text="Button2" android:layout_width="80dp" android:layout_height="80dp" android:id="@+id/button2" />
六、AbsoluteLayout(相对布局)
*可以确定准确的坐标值,代码是:
android:laoyout_x 确定水平的位置;
android:laoyout_y 确定竖直的位置;
以上就是我对六个布局的了解,希望以后更深入了解。
0 0
- 学习Layout总结
- dojo1.9学习总结(一)-layout
- size classes和layout的学习总结
- layout 总结
- Layout总结
- Layout学习
- Layout学习
- ExtJS学习笔记 layout的9种样式风格总结
- Android布局文件绘制原理学习总结 -- measure/layout/draw
- V-layout自我学习总结(自我记录)
- V-layout自我学习总结(自我记录)
- SWT中的Layout总结
- Android layout xml总结
- android layout 一步一步总结
- 实现layout总结
- Android layout xml总结
- android layout 入门总结
- Android layout xml总结
- .Net异步编程知多少
- 51nod-1163 最高的奖励(贪心)
- JavaScript基本概念
- leetcode
- rocketmq,IBM mq,kafka ,rabbitmq
- 学习Layout总结
- 字符串面试题
- PAT算法笔记(四)————锤子剪刀布
- 【bzoj3531】[SDOI2014]旅行
- android 获取HOME组件的Activity信息
- c语言实现通讯录(动态内存开辟)
- 抢救DB2数据之终极工具:db2dart
- 前端clearfix的理解
- MySQL安装配置,命令,异常纪要