1:在我们Android开发中,常见的布局的方式有6大类

  线性布局LinearLayout

  相对布局RelativeLayout

  表格布局TableLayout

  单帧布局FrameLayout

  绝对布局AbsoluteLayout

  瀑布流布局 recylerview(流行的)-----请查看------->友情链接 http://blog.csdn.net/zchlww/article/details/51524951

2:使用特点

使用最多的是:   线性布局LinearLayout , 相对布局RelativeLayout,  瀑布流布局 recylerview(流行的)

须知:开发中通常是布局与布局之间是相互嵌套使用的。

3:分析布局

线性布局LinearLayout

按照垂直或者水平的顺序依次排列子元素(如果不指定,默认为水平),每一个子元素都位于前一个元素之后。这样形成单行N列,

或者单列N行的布局;如果想要N行N列,可以嵌套使用LinearLayout。 看效果:

layout/main_out.xml

<LinearLayout 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" > <TextView
android:id="@+id/firstText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#FFFFFF"
android:text="@string/first" /> <TextView
android:id="@+id/secondText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#FFFF00"
android:text="@string/second" /> <TextView
android:id="@+id/thirdText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#FF00FF"
android:text="@string/third" /> <TextView
android:id="@+id/fourthText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#00FFFF"
android:text="@string/fourth" /> </LinearLayout>

效果如下

这里没有指定任何属性默认水平排布的,显示如下,可以看到4个标签水平依次排列:

现在略微修改一下代码,在LinearLayout节点内添加属性android:orientation="vertical",显示如下:

再来演示下N行N列的布局方法,使用嵌套结构,

    layout/testlinear.xml 文件

<?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" > <!-- 上半部分的区域的 -->
<LinearLayout
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#FFC90E"
> </LinearLayout> <!--下半部分的区域-->
<LinearLayout
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/green"
android:orientation="vertical"
> <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@color/red"
android:orientation="vertical" > </LinearLayout> <!--最下面有划分的那个线性的布局,相当于最后的那个div -->
<LinearLayout
android:baselineAligned="false"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="2.5"
android:background="@color/aqua"
android:orientation="horizontal"
> <!-- 这里开始的划分的了左边-->
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@color/coral"
> </LinearLayout> <LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1.78"
android:background="@color/burlywood" > </LinearLayout> <LinearLayout
android:layout_width="wrap_content"
android:layout_weight="1"
android:layout_height="match_parent"
android:background="@color/darkorange"
> </LinearLayout> </LinearLayout> </LinearLayout>
</LinearLayout>

效果图如下

--------------------------------------------------------------------------------------------

以上就是线性布局的特点。

Android布局6大类的更多相关文章

  1. Android布局---相对布局

    Android布局分为五大类:相对布局.线性布局.表格布局.帧布局.网格布局 相对布局 语法格式: <RelativeLayout xmlns:android="http://sche ...

  2. android中5大布局

    Android布局也可以用HTML5做,但是用户体验性差 Android布局里XML的属性配置 1. 五种Layout中Item的基础属性: layout_width & layout_hei ...

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

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

  4. 大礼包!ANDROID内存优化(大汇总)

    写在最前: 本文的思路主要借鉴了2014年AnDevCon开发者大会的一个演讲PPT,加上把网上搜集的各种内存零散知识点进行汇总.挑选.简化后整理而成. 所以我将本文定义为一个工具类的文章,如果你在A ...

  5. ANDROID内存优化——大汇总(转)

    原文作者博客:转载请注明本文出自大苞米的博客(http://blog.csdn.net/a396901990),谢谢支持! ANDROID内存优化(大汇总——上) 写在最前: 本文的思路主要借鉴了20 ...

  6. [置顶] Android布局管理器 - 详细解析布局实现

    布局管理器都是以ViewGroup为基类派生出来的; 使用布局管理器可以适配不同手机屏幕的分辨率,尺寸大小; 布局管理器之间的继承关系 : 在上面的UML图中可以看出, 绝对布局 帧布局 网格布局 相 ...

  7. Android 常用代码大集合 [转]

    [Android]调用字符串资源的几种方法   字符串资源的定义 文件路径:res/values/strings.xml 字符串资源定义示例: <?xml version="1.0&q ...

  8. Android学习链接大放送

    虽然贴链接这种事情..真是一种很偷懒的做法... 但是我一个小菜鸟,果断还是要以多向别人学习为主... 好资源要和大家分享对不对! 况且..放博客里..比收藏夹的利用几率要大一点! 原作者应该也很喜欢 ...

  9. ANDROID内存优化(大汇总——全)

    写在最前: 本文的思路主要借鉴了2014年AnDevCon开发者大会的一个演讲PPT,加上把网上搜集的各种内存零散知识点进行汇总.挑选.简化后整理而成. 所以我将本文定义为一个工具类的文章,如果你在A ...

随机推荐

  1. 三维场景中使用BillBoard技术

    三维场景中对于渲染效果不是很精致的物体可以使用BillBoard技术实现,使用该技术需要将物体实时朝向摄像机,即计算billboard的旋转矩阵M. 首先根据摄像机位置cameraPos和billBo ...

  2. ZeroC Ice 暂记

    摘自: http://weibo.com/p/1001603869896789339575 原文地址: http://www.oschina.net/question/865233_242146 吴治 ...

  3. arcgis将图片转成shp地图

    打开arcMap 1.右键[图层]-[属性]-[坐标系]-[地理坐标系]-双击"WGS 1984" 2.右键[图层]-[添加数据],打开图片文件-Band_2 3.右键图片-[属性 ...

  4. 19.dnw打不开

    用dnw.exe烧写文件时,突然出现电脑死机,重启后,dnw就打不开了,dnw.ini的原因,该文件在c盘目录下,只需要删除它,就可以继续使用dnw了.

  5. Struts2框架之-注解开发

    Struts2主要解决了从JSP到Action上的流程管理,如何进行Uri和action类中每个方法的绑定这是重点,在这里先简单看一下配置文件中的简单配置: <span style=" ...

  6. WIn7系统下 打开.exe程序出现已停止工作关闭程序之解决办法

    新装WIN7系统出现  .NET组建没有安装  可到官网下载安装 NETFx4.0 运行MVB 上位机SIM.EXE出现应用程序已停止工作问题 解决办法: 需关闭WIN7 DEP  如下 开始-运行( ...

  7. android Spinner的简单用法

    上代码: spinner = (Spinner) findViewById(R.id.spinner); tv = (TextView) findViewById(R.id.tv); final Ar ...

  8. AIX 环境下减小系统page space空间

    IBM AIX v5.3操作系统环境下减小系统page space空间详细步骤如下 1,创建一个临时的page space空间#mkps -a -n -s 20 rootvg 这里-a参数指定页面空间 ...

  9. C# MVC ( 将控制器的实体类注册到视图 )

    (1)控制器  代码 using System; using System.Collections.Generic; using System.Linq; using System.Web; usin ...

  10. Jenkins自动部署Tomcat项目

    Jenkins自动部署Tomcat项目 1.安装jenkins 插件 启动Jenkins,进入系统管理-插件管理: 选择Deploy to container Plugin 插件安装: