Linear Layout,Relative Layout
来源:互联网 发布:一个产品50元,淘宝拍摄 编辑:程序博客网 时间:2024/04/25 08:19
Linear Layout
- android:orientation
- android:layout_weight
子控件同等大小:android:layout_height 或者 android:layout_width 设为 “0pd”,设置android:layout_weight 为“1”。
例子:
<?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:paddingLeft="16dp" android:paddingRight="16dp" android:orientation="vertical" > <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="@string/to" /> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="@string/subject" /> <EditText android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:gravity="top" android:hint="@string/message" /> <Button android:layout_width="100dp" android:layout_height="wrap_content" android:layout_gravity="right" android:text="@string/send" /></LinearLayout>
Relative Layout
RelativeLayout支持的XML属性:
- android:gravity 设置布局容器内各个子组件的对齐方式
- android:ignoreGravity 设置哪个组件不受gravity属性的影响
RelativeLayout提供了一个内部类:RelativeLayout.LayoutParams,该类提供了大量的XML属性来控制RelativeLayout布局容器中子组件的布局分布。
RelativeLayout.LayoutParams中只能设为true、false的XML属性:
- android:layout_centerHorizontal 是否位于布局容器的水平居中
- android:layout_centerVertical 是否位于布局容器的垂直居中
- android:layout_centerInParent 是否位于布局容器的中央位置
- android:layout_alignParentBottom 是否与布局容器底端对齐
- android:layout_alignParentLeft 是否与布局容器左边对齐
- android:layout_alignParentRight 是否与布局容器右边对齐
- android:layout_alignParentTop 是否与布局容器顶端对齐
RelativeLayout.LayoutParams里属性为其他UI组件ID的XML属性:
- android:layout_toRightOf 子组件位于给出ID组件的右侧
- android:layout_toLeftOf 子组件位于给出ID组件的左侧
- android:layout_above 子组件位于给出ID组件的上方
- android:layout_below 子组件位于给出ID组件的下方
- android:layout_alignTop 子组件位于给出ID组件的上边界对齐
- android:layout_alignBottom 子组件位于给出ID组件的下边界对齐
- android:layout_alignLeft 子组件位于给出ID组件的左边界对齐
- android:layout_alignRight 子组件位于给出ID组件的右边界对齐
例子:
<?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" android:paddingLeft="16dp" android:paddingRight="16dp" > <EditText android:id="@+id/name" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="@string/reminder" /> <Spinner android:id="@+id/dates" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_below="@id/name" android:layout_alignParentLeft="true" android:layout_toLeftOf="@+id/times" /> <Spinner android:id="@id/times" android:layout_width="96dp" android:layout_height="wrap_content" android:layout_below="@id/name" android:layout_alignParentRight="true" /> <Button android:layout_width="96dp" android:layout_height="wrap_content" android:layout_below="@id/times" android:layout_alignParentRight="true" android:text="@string/done" /></RelativeLayout>
0 0
- Linear Layout,Relative Layout
- Layout--Linear与Relative
- Layout---Linear Layout和Relative Layout
- 布局(线性布局 Linear Layout )相对布局 (Relative Layout)
- Relative Layout
- Relative Layout
- Linear Layout
- Linear Layout
- Linear Layout
- Android开发教程 --- 布局(线性布局 Linear Layout )(相对布局 Relative Layout)
- Relative Layout相对布局
- android Relative Layout 属性
- Android Relative Layout
- Android布局relative layout
- 线性布局 Linear Layout
- Linear Layout 布局技巧
- Android Relative Layout 排列问题
- Relative Layout(相对布局)
- 操作系统——并发进程
- Java中Hashset、HashMap、ArrayList、LinkedList、Vector之间的联系与区别
- 四、sendRedirect()和forward()方法的区别 -----HttpServletResponse接口的sendRedirect()方法和RequestDispatcher接口的forw
- IOS高访新浪微博界面(讲解如何自定义UITableViewCell,处理@#链接 特殊字符)
- Java跨平台原理
- Linear Layout,Relative Layout
- 理解inode
- 设计模式笔记1 - 简单工厂 和 工厂模式理解以及使用
- C语言有哪些特点
- JSP 分页公用控件
- IOS block编程指南 4 声明和创建blocks
- 各种大型网站技术架构
- (1231)lightOJ
- c++ buffer is too small