<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控件及API说明(三)
  3. Android月历控件(DatePicker)和时间控件(TimePicker)的使用
  4. android之Spinner控件用法
  5. andirons studio五大布局简介
  6. 线性布局控件间的布局设置
  7. padding和margin的区别及其属性
  8. Android中的相对布局
  9. Android(安卓)EditText控件

随机推荐

  1. Android 视频深入解析
  2. 短视频源码安卓中的普通动画和属性动画的
  3. Android 网络通信框架Volley完全解析(一)
  4. 在Windows下搭建Android2.2开发环境
  5. Android wifi打开流程(Android O)
  6. Android中Media Framework浅析(一)——概述
  7. android异步线程为什么有这个错呢!
  8. Android之——AsyncTask和Handler对比
  9. Android中补间动画、属性动画效果演示
  10. Android canvas.drawXXX参数问题