android四种常见布局
来源:互联网 发布:淘宝怎么查看消费记录 编辑:程序博客网 时间:2024/06/17 00:53
A:线性布局
<?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="wrap_content" android:layout_height="wrap_content" android:text="按钮一" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="按钮二" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="按钮三" /> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:paddingTop="20dp" > <Button android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="按钮一" /> <Button android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="按钮二" /> <Button android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="按钮三" /> <Button android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="按钮四" /> </LinearLayout> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="right" android:text="按钮五" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="bottom" android:text="按钮六" /> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:background="#e0e0e0" android:gravity="center" > <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="按钮一" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="按钮二" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="按钮三" /> </LinearLayout></LinearLayout>
B:相对布局
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" > <Button android:id="@+id/middle" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:text="中间" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_above="@id/middle" android:layout_centerHorizontal="true" android:text="↑ " /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/middle" android:layout_centerHorizontal="true" android:text="↓" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerVertical="true" android:layout_toLeftOf="@id/middle" android:text="←" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerVertical="true" android:layout_toRightOf="@id/middle" android:text="→ " /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:text="东" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:text="西" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_alignParentTop="true" android:text="南" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_alignParentRight="true" android:text="北" /></RelativeLayout>
C:单帧布局
<?xml version="1.0" encoding="utf-8"?><FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" > <!-- 排下面 --> <TextView android:layout_width="200dp" android:layout_height="200dp" android:layout_gravity="center" android:background="#ff0000" /> <!-- 排上面 --> <TextView android:layout_width="300dp" android:layout_height="300dp" android:layout_gravity="center" android:background="#661100ff" /></FrameLayout>
D:表格布局
<?xml version="1.0" encoding="utf-8"?><TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center_vertical" android:padding="10dp" > <TableRow android:layout_width="match_parent" android:layout_height="wrap_content" > <TextView android:layout_width="80dp" android:layout_height="40dp" android:text="账户:" /> <EditText android:layout_width="0dp" android:layout_height="40dp" android:layout_weight="1" android:hint="请输入账号" /> </TableRow> <TableRow android:layout_width="match_parent" android:layout_height="wrap_content" > <TextView android:layout_width="80dp" android:layout_height="40dp" android:text="密码:" /> <EditText android:layout_width="0dp" android:layout_height="40dp" android:layout_weight="1" android:hint="请输入密码" android:inputType="textPassword" /> </TableRow> <TableRow android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingLeft="10dp" android:paddingRight="10dp" android:paddingTop="30dp" > <Button android:layout_width="0dp" android:layout_weight="1" android:height="40dp" android:text="退出" /> <Button android:layout_width="0dp" android:layout_marginLeft="20dp" android:layout_weight="1" android:height="40dp" android:text="登录" /> </TableRow></TableLayout>
E:下载链接
http://download.csdn.net/detail/qq_30266985/9683838
0 0
- android四种常见布局
- app-android中常见的四种布局
- Android 四种布局
- android的四种布局
- Android四种布局管理器
- android-四种基本布局
- Android四种基本布局
- Android, 四种基本布局
- Android四种常用布局
- Android四种常用布局
- 【Android】四种基本布局
- Android四种基本布局
- Android四种基本布局
- Android中的四种布局
- Android四种常见动画
- Android之---五种常见布局
- Android常见布局简述
- android 常见布局方式
- 文字,Logo到模型制作详解
- BZOJ2553: [BeiJing2011]禁忌
- zepto和jquery的区别小结
- 密码的输入带*号,可删除
- struts2 学习日志1
- android四种常见布局
- Java集合简述
- CCS6编译出现的问题总结及解决办法
- 排列组合的解决办法
- 放苹果——华为机试题
- 虚幻引擎源码分析(4)
- 如何再IDEA 上使用java web开发
- NFC的读写卡模式——前台调度系统
- Oracle11g字符集AL32UTF8与ZHS16GBK相互转换