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. text-align:justify 使用参考

    对 text-align:justify 不大了解的,可以先看这里:从css text-align:justify 谈谈 text-align 文本对齐方式,讲的比较浅显易懂,本篇相对深入些,最好先看 ...

  2. POJ 2253 Frogger【最短路变形——路径上最小的最大权】

    链接: http://poj.org/problem?id=2253 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=22010#probl ...

  3. Powershell运行Invoke-Sqlcmd命令的先决条件

    运行Invoke-Sqlcmd命令,使用这个命令需满足如下条件: 1.在运行服务器中安装SQL Server 2008 R2 Management ObjectsI 2.在运行命令 invoke-sq ...

  4. Audit File Delete

    OPEN 4656 ACCESS   4663 AN OBJECT WAS DELETED 4660 CLOSE 4658 1537 = Delete 1538 = Read_CONTROL 1541 ...

  5. Centos 软链接命令(十)

    链接命令:ln  (link) ln -s [源文件] [目标文件] 功能描述:生成链接文件 选项: -s 创建软链接 硬链接特征: 1,拥有相同的i节点和存储block块,可以看作是同一个文件: 2 ...

  6. 总结学习! xml与java对象转换 --- JDK自带的JAXB(Java Architecture for XML Binding)

    JAXB(Java Architecture for XML Binding) 是一个业界的标准,是一项可以根据XML Schema产生Java类的技术.该过程中,JAXB也提供了将XML实例文档反向 ...

  7. 最全的sublime插件整理

    Package Control 插件管理器 1)在Sublime中打开View –> Show Console,将以下代码复制到输入框中后按回车键 import urllib.request,o ...

  8. C#检测两个文件内容是否相同

    不知道为什么对Excel 2010 xlsx后缀的文件没有效果,求解! 对其他文件有效,如.txt,.csv using System; using System.Security.Cryptogra ...

  9. vue之 node.js 的简单介绍

    一.什么是 node.js? 它是可以运行在JavaScript的服务平台 二.安装 1.node.js的特性 - 非阻塞IO模型 - 时间驱动 2.运用场景 - 高并发低业务 - 实时场景 - 聊天 ...

  10. 初识JS 基本语法.基本运算符

    JavaScript概述 JavaScript的历史 1992年Nombas开发出C-minus-minus(C--)的嵌入式脚本语言(最初绑定在CEnvi软件中).后将其改名ScriptEase.( ...