<LinearLayout

android:id="@+id/linearLayout1"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:orientation="vertical" >

线性布局,默认是水平对齐horizontal,vertical是垂直对齐可以嵌套使用LinearLayout

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="fill_parent"    android:layout_height="fill_parent"    android:orientation="vertical" >    <LinearLayout        android:id="@+id/linearLayout1"        android:layout_width="fill_parent"        android:layout_height="wrap_content"        android:orientation="vertical" >        <EditText            android:id="@+id/editText1"            android:layout_width="fill_parent"            android:layout_height="wrap_content" >        </EditText>    </LinearLayout>    <LinearLayout        android:id="@+id/linearLayout2"        android:layout_width="fill_parent"        android:layout_height="wrap_content"         android:orientation="horizontal"         android:gravity="right" >                <Button            android:id="@+id/button1"            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:text="@string/submit" />        <Button            android:id="@+id/button2"            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:text="@string/cancle" />    </LinearLayout></LinearLayout>

absoluteLayout绝对布局

制定子控件的xy精确坐标

绝对布局,缺乏灵活性,官方不推荐使用

FrameLayout 框架布局,是以叠层的形式布局

用layout_gravity=“left|top” 这个属性控制子控件显示的位子

RelativeLayout 相对布局

android:layout_alignBaseline 该控件基线对齐给定ID的基线

android:layout_alignBottom 该控件于给定ID的控件底部对齐

android:layout_alignLeft 该控件于给定ID的控件左对齐

android:layout_alignRight 该控件于给定ID的控件右对齐

android:layout_alignTop 该控件于给定ID的控件顶对齐


android:layout_above 将该控件置于给定ID的控件之上

android:layout_below 将该控件的置于给定ID控件之下

android:layout_toLeftOf 将该控件置于给定ID的控件之左

android:layout_toRightOf 将该控件置于给定ID的控件之右

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="fill_parent"    android:layout_height="fill_parent">    <TextView        android:id="@+id/txt01"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="111"        android:background="#ff0000"         />    <TextView        android:id="@+id/txt02"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="222"        android:background="#00ff00"        android:layout_below="@+id/txt01"         /></RelativeLayout>

android:layout_below="@+id/txt01"意思是当前textview在id=txt01的textview空间之下



<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="fill_parent"    android:layout_height="fill_parent"                    android:padding="10dp"    >    <TextView        android:id="@+id/txt01"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="22222"        android:background="#ff0000"         />    <EditText         android:id="@+id/edit01"        android:layout_width="fill_parent"        android:layout_height="wrap_content"        android:layout_below="@id/txt01"        android:layout_marginTop="10dp"                />    <Button         android:id="@+id/btn01"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="确认"android:layout_below="@id/edit01"android:layout_alignParentRight="true"        />    <Button         android:id="@+id/btn02"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_toLeftOf="@id/btn01"          android:layout_below="@id/edit01"           android:text="取消"                     />       </RelativeLayout>

android:layout_toLeftOf="@id/btn01" //在button1的左边

android:layout_below="@id/edit01" //在edittext的下面

另外有一个android:layout_aliginBaseLine="@id+/btn"用法 是textview以button 的文字对齐

<TextView

        android:id="@+id/txt01"        android:layout_width="wrap_content"        android:layout_height="wrap_content"   android:layout_aliginBaseLine="@id+/btn         />
  <Button 
        android:id="@+id/btn"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="取消"                  />

TableLayout常用的属性:

下面放在tablelayout中

android:collapseColumns:隐藏指定的列(数组)

android:shrinkColumns:收缩指定的列以适合屏幕,不会挤出屏幕(数组)

android:stretchColumns:尽量把指定的列填充空白部分

下面方在tableRow

android:layout_column:控件放在指定的列

android:layout_span:该控件所跨越的列数


<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="fill_parent"    android:layout_height="fill_parent"  android:collapseColumns="0,1"    android:shrinkColumns="2"    android:stretchColumns="1"    ><TableRow><Buttonandroid:text="Button11"/><Buttonandroid:text="Button12"/><Buttonandroid:text="Button13"/></TableRow><TableRow><Buttonandroid:text="Button21"/><Buttonandroid:layout_span="2"android:text="Button23"
/></TableRow>    </TableLayout>

可以嵌套使用

更多相关文章

  1. android 布局边框
  2. Android入门学习七:基本控件学习
  3. android 表单布局 左右布局
  4. android之Spinner控件用法
  5. Android控件及API说明(三)
  6. Android常用布局之LinearLayout(线性布局)仿酷狗登录界面
  7. 线性布局控件间的布局设置
  8. android的布局属性(转)
  9. Android中的相对布局

随机推荐

  1. 编写MySQL Shell插件(REPORT)
  2. 实战:一文带你解决Mysql主从复制日常错误
  3. MySQL的Hash Join能用吗?
  4. 实战:从Mysql数据库frm文件中,提取表结构创
  5. MySQL的Bugs
  6. join为啥会阻塞主线程?
  7. 揭秘一条select语句,在MySQL中权限访问控
  8. MySQL的最低硬件要求?
  9. Linux下Shell的for循环语句N种写法
  10. MySQL8.0.20 正式发行(GA)