Android学习(7)-UI布局
来源:互联网 发布:低通滤波算法原理 编辑:程序博客网 时间:2024/06/05 09:55
布局中可以包含布局和控件。
(1)LinerLayout
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="<strong>horizontal</strong>" > <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" <strong>android:layout_gravity="top"</strong> android:text="Button1" /> <Button android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:text="Button2" /> <Button android:id="@+id/button3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="bottom" android:text="Button3" /></LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal" > <EditText android:id="@+id/edit_text" android:layout_width="0dp" <strong>android:layout_weight="2"</strong> android:layout_height="wrap_content" android:hint="Type something" /> <Button android:id="@+id/button1" android:layout_width="0dp" <strong>android:layout_weight="1"</strong> android:layout_height="wrap_content" android:text="Send" /></LinearLayout>根据比例布置控件。
(2)RelativeLayout
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" > <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" <strong>android:layout_alignParentLeft="true" android:layout_alignParentTop="true"</strong> android:text="Button" /> <Button android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_alignParentTop="true" android:text="Button" /> <Button android:id="@+id/button3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:text="Button" /> <Button android:id="@+id/button4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_alignParentLeft="true" android:text="Button" /> <Button android:id="@+id/button5" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_alignParentRight="true" android:text="Button" /></RelativeLayout>以上是相对于布局排列控件。下面是相对于控件排列控件:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" > <Button android:id="@+id/button3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:text="Button" /> <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_above="@+id/button3" android:layout_toLeftOf="@+id/button3" android:text="Button" /> ......</RelativeLayout>
(3)FrameLayout
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" > <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" /> <ImageView android:id="@+id/imageView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/ic_launcher" /></FrameLayout>
(4)TableLayout
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" > <strong><TableRow</strong> android:id="@+id/tableRow1" android:layout_width="wrap_content" android:layout_height="wrap_content" > <TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="TextView" /> <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" /> </TableRow></TableLayout>
0 0
- Android学习(7)-UI布局
- android UI学习笔记(布局)
- Android UI学习笔记------布局
- android学习笔记---UI布局
- Android UI 学习 自定义的布局 平滑移动 VelocityTracker()
- Android开发学习笔记--UI布局(1)
- Android UI学习 - FrameLayou和布局优化
- Android UI学习 - FrameLayou和布局优化
- Android UI学习 - FrameLayou和布局优化
- Android UI学习 - FrameLayou和布局优化
- Android UI学习 - FrameLayou和布局优化
- Android UI学习 - FrameLayou和布局优化
- Android学习之 UI布局优化
- Android UI学习 - FrameLayou和布局优化
- Android学习手记(5) 基本UI布局
- Android UI学习 - FrameLayou和布局优化
- Android UI学习 - FrameLayou和布局优化
- Android UI学习和布局优化
- IOS中获取各种文件的目录路径的方法
- 成为优秀高级程序员的10个要点
- 自学需静心
- extern ”C"的使用
- android应用程序如何调用支付宝接口
- Android学习(7)-UI布局
- 解决 spring mvc 3.0 结合 hibernate3.2 使用<tx:annotation-driven>声明式事务无法提交的问题
- oracle 11g 安装
- LeetCode169——Majority Element
- 黑马程序员——Jave之反射
- BZOJ 3601 一个人的数论 莫比乌斯反演+高斯消元
- Matlab中的input命令
- linux和windows之间上传 下载文件 非ftp方式
- JSON 学习