1. 相对布局

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" > <TextView
android:id="@+id/tv_phone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="请输入手机号" /> <EditText
android:id="@+id/et_phone"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/tv_phone"
android:hint="手机号" /> <TextView
android:id="@+id/tv_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/et_phone"
android:text="请输入短信内容" /> <EditText
android:id="@+id/et_content"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/tv_content"
android:hint="短信内容"
android:inputType="textMultiLine"
android:minLines="5" /> <Button
android:layout_alignParentRight="true"
android:layout_below="@id/et_content"
android:text="发送短信"
android:layout_width="wrap_content"
android:layout_height="wrap_content" /> </RelativeLayout>

2.  线性布局

<?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:orientation="vertical" > <RelativeLayout android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/tv1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="XXXXXXX"
android:textSize="20sp" />
<TextView
android:id="@+id/tv2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/tv1"
android:text="YYYYYYYYYYY"
android:textSize="15sp" />
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerInParent="true"
/>
</RelativeLayout> <View
android:layout_width="match_parent"
android:layout_height="0.1dp"
android:background="#88000000"
/> <RelativeLayout android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/tv12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="XXXXXXX"
android:textSize="20sp" />
<TextView
android:id="@+id/tv22"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/tv12"
android:text="YYYYYYYYYYY"
android:textSize="15sp" />
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerInParent="true"
/>
</RelativeLayout> <View
android:layout_width="match_parent"
android:layout_height="0.1dp"
android:background="#88000000"
/> </LinearLayout>

3. 表格布局

<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" > <TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content" > <!--width=0,设置weight 权重, 显示比例-->
<TextView
android:gravity="center"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="用户名" /> <EditText
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="2" />
</TableRow> <TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content" > <TextView
android:gravity="center"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="密码" /> <EditText
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="2"
android:inputType="textPassword" />
</TableRow> </TableLayout>

4. 绝对布局

<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" > <Button
android:id="@+id/button2"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="62dp"
android:layout_y="318dp"
android:text="Button" /> <ToggleButton
android:id="@+id/toggleButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="59dp"
android:layout_y="46dp"
android:text="ToggleButton" /> <CheckBox
android:id="@+id/checkBox1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="39dp"
android:layout_y="134dp"
android:text="CheckBox" /> <Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="237dp"
android:layout_y="61dp"
android:text="Button" /> </AbsoluteLayout>

5.帧布局

几层控件跌在一起, 可以控制显示那一层,应用场景: 播放器暂停时的暂停图标。

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" > <LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#88000000" >
</LinearLayout> <ImageView
android:visibility="visible"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="center"
android:src="@drawable/ic_launcher" /> </FrameLayout>

Android -- UI布局管理,相对布局,线性布局,表格布局,绝对布局,帧布局的更多相关文章

  1. Android零基础入门第30节:两分钟掌握FrameLayout帧布局

    原文:Android零基础入门第30节:两分钟掌握FrameLayout帧布局 前面学习了线性布局.相对布局.表格布局,那么本期来学习第四种布局--FrameLayout帧布局. 一.认识FrameL ...

  2. 从头学Android之Android布局管理:LinerLayout线性布局

    LinerLayout线性布局: 这种布局方式是指在这个里面的控件元素显线性,我们可以通过setOrientation(int orientation)来指定线性布局的显示方式,其值有:HORIZON ...

  3. Android布局管理器(线性布局)

    线性布局有LinearLayout类来代表,Android的线性布局和Swing的Box有点相似(他们都会将容器里面的组件一个接一个的排列起来),LinearLayout中,使用android:ori ...

  4. android开发4:Android布局管理器1(线性布局,相对布局RelativeLayout-案例)

    控件类概述 View 可视化控件的基类 属性名称 对应方法 描述 android:background setBackgroundResource(int) 设置背景 android:clickabl ...

  5. Android UI组件:布局管理器

    为了更好的管理Android应用的用户界面中的组件,Android提供了布局管理器.通过使用布局管理器,Android应用的图形用户界面具有良好的平台无关性.通常,推荐使用布局管理器来管理组件的分布. ...

  6. 第1组UI组件:布局管理器

    1 布局管理的来源 为了让UI在不同的手机屏幕上都能运行良好----不同手机屏幕的分辨率/尺寸并不完全相同,如果让程序手动控制每个组件的大小.位置,会给编程带来巨大的麻烦.为了解决这个问题.andro ...

  7. 【Android应用开发技术:用户界面】布局管理器

    作者:郭孝星 微博:郭孝星的新浪微博 邮箱:allenwells@163.com 博客:http://blog.csdn.net/allenwells Github:https://github.co ...

  8. android中常用的布局管理器

    Android中的几种常用的布局,主要介绍内容有: View视图 RelativeLayout    相对布局管理器 LinearLayout     线性布局管理器 FrameLayout     ...

  9. Android零基础入门第71节:CardView简单实现卡片式布局

    还记得我们一共学过了多少UI控件了吗?都掌握的怎么样啊. 安卓中一些常用控件学习得差不多了,今天再来学习一个新的控件CardView,在实际开发中也有非常高的地位. 一.CardView简介 Card ...

  10. PyQT5速成教程-3 布局管理

    本文由 沈庆阳 所有,转载请与作者取得联系! 布局(Layout)管理 Qt Designer中,在工具箱中最上方可以看到有4种布局.分别是垂直布局.水平布局.栅格布局和表单布局.   四种布局 布局 ...

随机推荐

  1. 【BZOJ1996】[Hnoi2010]chorus 合唱队 区间DP

    [BZOJ1996][Hnoi2010]chorus 合唱队 Description Input Output Sample Input 4 1701 1702 1703 1704 Sample Ou ...

  2. 如何修改Myeclipse的JSP模板

    先找到MyEclipse的安装目录, 再找到myeclipse/eclipse/plugins/com.genuitec.eclipse.wizards_5.1.0/templates/jsp (co ...

  3. mfc 对话框程序 托盘实现

    1 在头文件里面定义 消息 #define WM_SHOWTASK WM_USER+10 在主窗口类里面定义 一个变量 两个函数 a 变量 托盘结构体的变量 NOTIFYICONDATA m_nid; ...

  4. Chomsky_hierarchy

      Grammar Languages Automaton Production rules (constraints) Type-0 Recursively enumerable Turing ma ...

  5. root Permission denied

    w 遇见现象,原因待查

  6. python系列十六:Python3 面向对象

    #!/usr/bin/python #-*-coding:gbk-*- #Python3 面向对象 '''面向对象技术简介    类(Class): 用来描述具有相同的属性和方法的对象的集合.它定义了 ...

  7. 【POJ3615】Cow Hurdles 最短路,你若LCA,我仍不拦你。

    NOIP2013货车运输.仅仅只是数据范围小了很多. 不到150s打完而且AC. . 额.当然.我写的是Floyd. 写LCA的真过分. #include <cstdio> #includ ...

  8. MySQL读写分离之amoeba

    MySQL读写分离之amoeba主从复制的搭建环境参考:http://www.cnblogs.com/fansik/p/5270334.htmlamoeba依赖于jdk环境:jdk环境搭建参考:htt ...

  9. go——反射

    反射(reflect)让我们能在运行期探知对象地类型信息和内存结构,这从一定程度上弥补了静态语言在动态行为上地不足.和C数据结构一样,Go对象头部并没有类型指针,通过其自身是无法在运行期获知任何类型相 ...

  10. rsync+inotify实时同步

    !!!在安装前要先确保,rsync daemon服务配置成功,在安装inotify-tools前先确认你的linux内核是否达到了2.6.13,并且在编译时开启CONFIG_INOTIFY选项,也可以 ...