一、线性布局----LinearLayout

   horizontal 水平

<?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="horizontal" > <Button
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="按钮1"
/>
<Button
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="按钮2"
/>
<Button
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="按钮3"
/>
</LinearLayout>

  vertical  垂直 

<?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" > <Button
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="按钮1"
/>
<Button
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="按钮2"
/>
<Button
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="按钮3"
/>
</LinearLayout>

如果你可以看懂了,那请做一个来练练手

参考答案:http://www.cnblogs.com/896240130Master/p/6090786.html

二、相当布局----RelativeLayout

RelativeLayout是Android五大布局结构中最灵活的一种布局结构,比较适合一些复杂界面的布局。

按照各子元素之间的位置关系完成布局。在此布局中的子元素里与位置相关的属性将生效。例如android:layout_below,  android:layout_above, android:layout_centerVertical等。注意在指定位置关系时,引用的ID必须在引用之前,先被定义,否则将出现异常。

默认左上角。所以使用的时候会重叠

我们可以加上你在哪个布局的下面:下图

android:layout_below="@id/xxxx" //在谁的下面

参考属性:

  1. android:layout_above                                       将该控件的底部至于给定ID的控件之上
  2. android:layout_below                                       将该控件的顶部至于给定ID的控件之下
  3. android:layout_toLeftOf                                    将该控件的右边缘和给定ID的控件的左边缘对齐
  4. android:layout_toRightOf                                 将该控件的左边缘和给定ID的控件的右边缘对齐
  5. android:layout_alignBaseline                           该控件的baseline和给定ID的控件的baseline对齐
  6. android:layout_alignBottom                             将该控件的底部边缘与给定ID控件的底部边缘
  7. android:layout_alignLeft                                  将该控件的左边缘与给定ID控件的左边缘对齐
  8. android:layout_alignRight                                将该控件的右边缘与给定ID控件的右边缘对齐
  9. android:layout_alignTop                                 将给定控件的顶部边缘与给定ID控件的顶部对齐
  10. android:alignParentBottom                              如果该值为true,则将该控件的底部和父控件的底部对齐
  11. android:layout_alignParentLeft                       如果该值为true,则将该控件的左边与父控件的左边对齐
  12. android:layout_alignParentRight                    如果该值为true,则将该控件的右边与父控件的右边对齐
  13. android:layout_alignParentTop                      如果该值为true,则将空间的顶部与父控件的顶部对齐
  14. android:layout_centerHorizontal                     如果值为真,该控件将被至于水平方向的中央
  15. android:layout_centerInParent                       如果值为真,该控件将被至于父控件水平方向和垂直方向的中央
  16. android:layout_centerVertical                        如果值为真,该控件将被至于垂直方向的中央

结果图如下:

三、帧布局------FrameLayout

FrameLayout是五大布局中最简单的一个布局,可以说成是层布局方式。在这个布局中,整个界面被当成一块空白备用区域,所有的子元素都不能被指定放置的位置,它们统统放于这块区域的左上角,并且后面的子元素直接覆盖在前面的子元素之上,将前面的子元素部分和全部遮挡。如下,第一个TextView被第二个TextView完全遮挡,第三个TextView遮挡了第二个TextView的部分位置。

待更新。。。。

四、表格布局----TableLayout

代码如下:

<?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 代表一行 -->
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"> <TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="一行一列"
android:textSize="20sp"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="一行二列"
android:layout_marginLeft="30dp"
/>
</TableRow> <!-- tablerow 代表一行 -->
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"> <TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#FF7F50"
android:text="二行一列"
android:textSize="20sp"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="二行二列"
android:layout_marginLeft="30dp"
/>
</TableRow> </TableLayout>

五、绝对布局---谷歌工程师已经废弃掉了。这里就不多加了解

Android 中常用的布局的更多相关文章

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

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

  2. Android中常用的布局

    一般分为5大类. Android中所有的空间第一字母都是大写 1.线性布局 LinearLayout 2.相对布局 RelativeLayout 3.帧布局--分层显示  FrameLayout 4. ...

  3. android中常用的布局管理器(二)

    接上篇博客 (3)LinearLayout     线性布局管理器 线性布局管理器是将放入其中的组件按照垂直或水平方向来布局,每一行或每一列只能放一个组件,并且不会换行,当组件排列到窗体的边缘后,后面 ...

  4. 四种方式写按钮点击事件和Android 中常用的布局

    1.匿名内部类的方式 2.创建一个类实现onClickListener,实现onClick方法,设置控件点击时传一个类的对象 3.让当前类实现onClickListener,设置控件点击事件时传递一个 ...

  5. Android中的五大布局

    Android中的五大布局 1.了解布局 一个丰富的界面总是要由很多个控件组成的,那我们如何才能让各个控件都有条不紊地 摆放在界面上,而不是乱糟糟的呢?这就需要借助布局来实现了.布局是一种可用于放置很 ...

  6. Android中的LinearLayout布局

    LinearLayout : 线性布局 在一般情况下,当有很多控件需要在一个界面列出来时,我们就可以使用线性布局(LinearLayout)了,  线性布局是按照垂直方向(vertical)或水平方向 ...

  7. Android中常用的5大布局详述

    Android的界面是有布局和组件协同完成的,布局好比是建筑里的框架,而组件则相当于建筑里的砖瓦.组件按照布局的要求依次排列,就组成了用户所看见的界面. 所有的布局方式都可以归类为ViewGroup的 ...

  8. Android中常用布局单位

    Android在UI布局时经常用到一些单位,对单位混用直接会影响UI的显示,要想正确的在布局中使用每种单位就必须先真正的熟悉它. UI显示效果的影响因素:屏幕尺寸.屏幕密度.分辨率:而android手 ...

  9. Android中常用控件及属性

    在之前的博客为大家带来了很多关于Android和jsp的介绍,本篇将为大家带来,关于Andriod中常用控件及属性的使用方法,目的方便大家遗忘时,及时复习参考.好了废话不多讲,现在开始我们本篇内容的介 ...

随机推荐

  1. Java Web开发框架Spring+Hibernate整合效果介绍(附源码)

    最近花了一些时间整合了一个SpringMVC+springAOP+spring security+Hibernate的一套框架,之前只专注于.NET的软件架构设计,并没有接触过Java EE,好在有经 ...

  2. 【python】pymongo查找某一时间段的数据

    python中实现: 下面代码就是查找2016-09-26 00:00:00 ~ 2016-09-27 00:00:00 时间段的数据 from datetime import datetimefor ...

  3. 如何更改UITextField 的placeholder 的字体颜色

    storyboard 中这样设置 具体步骤: 1.在User Defined Runtime Attributes中添加一个Key. 2.输入Key Path(这里我们输入_placeholderLa ...

  4. [Android Pro] How to get recent tasks on Android “L”?

    reference : http://stackoverflow.com/questions/24590533/how-to-get-recent-tasks-on-android-l/2688546 ...

  5. qt_文本编辑器实现_附带详细注释和源码下载

    源码下载: 链接: http://pan.baidu.com/s/1c21EVRy 密码: qub8 实现主要的功能有:新建,打开,保存,另存为,查找(查找的时候需要先将光标放到最下面位置才能查全,不 ...

  6. 设计模式之构建者模式(Builder):初步理解

    构建者(Builder)设计模式(又叫生成器设计模式): 当一个类的内部数据过于复杂的时候(通常是负责持有数据的类,比如Config.VO.PO.Entity...),要创建的话可能就需要了解这个类的 ...

  7. hdu 2602

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2602 #include<cstdio> #include<iostream> ...

  8. probe函数何时调用的

    转自:http://blog.csdn.net/xiafeng1113/article/details/8030248 Linux中 probe函数何时调用的 所以的驱动教程上都说:只有设备和驱动的名 ...

  9. Linux(CentOS)常用操作指令(一)

    基本指令集合 1.查看CentOS版本信息 cat /proc/version cat /etc/redhat-release 2.查看安全日志文件信息 tail -f /var/log/secure ...

  10. 那些年,我们在Django web开发中踩过的坑(一)——神奇的‘/’与ajax+iframe上传

    一.上传图片并在前端展示 为了避免前端整体刷新,我们采用ajax+iframe(兼容所有浏览器)上传,这样用户上传之后就可以立即看到图片: 上传前: 上传后: 前端部分html: <form s ...