Android 简单布局LinearLayout、table、frame、relative
来源:互联网 发布:如何防止盗取网页源码 编辑:程序博客网 时间:2024/06/07 01:55
源码下载↓↓↓
基本的布局方式,做了几个测试,都是属性配置什么的。不需要说明,直接上代码:
线性布局-LinearLayout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <TextView android:id="@+id/textView1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="right" android:text="TextView" /> <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:text="C" /> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:text="+/-" /> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:text="/" /> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:text="*" /> </LinearLayout> <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:text="7" /> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:text="8" /> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:text="9" /> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:text="-" /> </LinearLayout> <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:text="4" /> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:text="5" /> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:text="6" /> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:text="+" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="93dp" android:layout_weight="1" android:orientation="horizontal" > <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:orientation="vertical" > <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:text="1" /> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:text="2" /> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:text="3" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:text="0" /> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="2" android:text="." /> </LinearLayout> </LinearLayout> <Button android:layout_width="match_parent" android:layout_height="99dp" android:layout_weight="3" android:text="=" /> </LinearLayout></LinearLayout>frame布局:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" > <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/big" android:layout_gravity="center" android:text="button" /> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/qie" android:layout_marginTop="100dp" android:text="button" /> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/juhua" android:layout_marginLeft="100dp" android:text="button" /></FrameLayout>相对布局-relative:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"> <Button android:id="@+id/button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:text="button" /> <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_above="@id/button" android:layout_toLeftOf="@id/button" android:text="button1" /> <Button android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_above="@id/button" android:layout_toRightOf="@id/button" android:text="button2" /> <Button android:id="@+id/button3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/button" android:layout_toRightOf="@id/button" android:text="button3" /> <Button android:id="@+id/button4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/button" android:layout_toLeftOf="@id/button" android:text="button4" /></RelativeLayout>
table布局:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" ><TableLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:stretchColumns="0,1,2,3"> <TableRow > <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="button1" /> <Button android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="button2" /> <Button android:id="@+id/button3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="button3" /> <Button android:id="@+id/button4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="button4" /> </TableRow></TableLayout><TableLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:stretchColumns="0"> <TableRow android:layout_width="fill_parent" android:layout_height="fill_parent"> <EditText android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center" android:text="button1" /> </TableRow></TableLayout></LinearLayout>点击下载源码
0 0
- Android 简单布局LinearLayout、table、frame、relative
- android中截获软键盘
- Android屏幕旋转处理,保持Activity内容
- Android体系结构
- Android的String用法
- Android+push+notification方案比较
- Android Intent对应的category类别大全
- Android 中添加 AT 命令流程
- Cannot find or open the PDB file解决方案
- Hibernate discriminator-value用法
- Android RelativeLayout属性大全
- MFC API——》PreCreateWindow
- Linux中error while loading shared libraries错误解决办法
- fatal error C1083: Cannot open precompiled header
- Windows IO处理流程浅析(IRP)
- oracle_SQL中ROWID与ROWNUM的使用
- Cookie and Session
- Android Bluetooth详解(Android英文文档相关译文)
- 开源重磅,java内容管理系统CMS,点击即可编辑,保存,轻松构建自己的网站
- CSDN 博客排版技巧
- POJ 1131 Octal Fractions
- Oracle SCN详解
- IOS日历控件界面改写
- Android 简单布局LinearLayout、table、frame、relative
- 字符串命名空间
- 【图文】把jar打包成exe并在无java环境的电脑上运
- 1102: 机器翻译(translate)
- 抓包分析HTTP/HTTPS请求,写12306抢票软件
- ubuntu常用的截图方法
- ruby class_eval的使用
- 算法基础(八):超详细最优二叉树构建(1)
- python的threading模块中threading.RLock和threading.Lock