Android学习-Layout布局
来源:互联网 发布:淘宝店铺风格定位 编辑:程序博客网 时间:2024/06/04 10:09
由于之前学习的时候还没有开始写博客,这里写一下就当做是复习一下。
LinearLayout
首先是LinearLayout里面的属性
举个例子:
<Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="50dp" android:text="哈哈哈"/>
效果如下
改为padding
<Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingLeft="50dp" android:text="哈哈哈"/>
效果如下
RelativeLayout
相对布局,属性相对来说比LinearLayout多点
举个列子:
<Button android:id="@+id/btn_center" 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_alignRight="@id/btn_center" android:text="alignRight中心" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_alignParentBottom="true" android:text="ParentRight和Bottom" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignTop="@id/btn_center" android:layout_toRightOf="@id/btn_center" android:text="alignTop、toRightOf中心" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_above="@id/btn_center" android:text="above中心" />
效果图
TableLayout
表格布局
表格布局的行数是由TableRow来决定,列数由列数最多的那个TableRow来决定
常见的属性有
做个列子
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" > <TableLayout android:layout_width="250dp" android:layout_height="match_parent" android:layout_centerHorizontal="true" android:stretchColumns="1" > <TableRow android:layout_height="wrap_content"> <Button android:layout_height="wrap_content" android:text="账户"/> <EditText android:layout_height="wrap_content" android:hint="输入账号"/> </TableRow> <TableRow android:layout_height="wrap_content"> <Button android:layout_height="wrap_content" android:text="密码"/> <EditText android:layout_height="wrap_content" android:hint="输入密码"/> </TableRow> <TableRow android:layout_height="wrap_content"> <Button android:layout_height="wrap_content" android:layout_span="2" android:text="登录"/> </TableRow> </TableLayout></RelativeLayout>
效果图
这里隐藏了标题栏,只需在setContentView之前加入
requestWindowFeature(Window.FEATURE_NO_TITLE);
即可
0 0
- Android学习-Layout布局
- Android Layout学习 自己layout 布局中的item
- android学习之布局(layout)
- Android学习笔记05:布局Layout介绍
- android基础学习之六大Layout布局
- Extjs学习 layout布局
- layout布局的学习
- Android Layout各种布局
- Android Layout 布局教材
- android 布局(Layout)资源共享
- Android之layout布局
- Android Layout 布局
- Android Layout 布局
- Android Layout布局属性
- android layout各种布局
- Android Layout 布局
- android界面布局layout
- Android中的布局 Layout
- linux下把eth1改为eth0
- iOS 设置头像圆角效果
- UTF-8编码规则(转)
- 80. Remove Duplicates from Sorted Array II LeetCode
- div水平居中与垂直居中
- Android学习-Layout布局
- <Torch>~解惑篇-1.深度学习平台的选择(溪欲焰)
- jsoup 解析HTML信息
- Windbg调试命令详解
- zlib的交叉编译 for海思
- 前端猿的成长历程
- hrbust 哈理工oj 2011 一等队形【dp】
- 博客记录
- 【Java-IO】IO入门