Android布局6大类
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大类的更多相关文章
- Android布局---相对布局
Android布局分为五大类:相对布局.线性布局.表格布局.帧布局.网格布局 相对布局 语法格式: <RelativeLayout xmlns:android="http://sche ...
- android中5大布局
Android布局也可以用HTML5做,但是用户体验性差 Android布局里XML的属性配置 1. 五种Layout中Item的基础属性: layout_width & layout_hei ...
- 从头学Android之Android布局管理:LinerLayout线性布局
LinerLayout线性布局: 这种布局方式是指在这个里面的控件元素显线性,我们可以通过setOrientation(int orientation)来指定线性布局的显示方式,其值有:HORIZON ...
- 大礼包!ANDROID内存优化(大汇总)
写在最前: 本文的思路主要借鉴了2014年AnDevCon开发者大会的一个演讲PPT,加上把网上搜集的各种内存零散知识点进行汇总.挑选.简化后整理而成. 所以我将本文定义为一个工具类的文章,如果你在A ...
- ANDROID内存优化——大汇总(转)
原文作者博客:转载请注明本文出自大苞米的博客(http://blog.csdn.net/a396901990),谢谢支持! ANDROID内存优化(大汇总——上) 写在最前: 本文的思路主要借鉴了20 ...
- [置顶] Android布局管理器 - 详细解析布局实现
布局管理器都是以ViewGroup为基类派生出来的; 使用布局管理器可以适配不同手机屏幕的分辨率,尺寸大小; 布局管理器之间的继承关系 : 在上面的UML图中可以看出, 绝对布局 帧布局 网格布局 相 ...
- Android 常用代码大集合 [转]
[Android]调用字符串资源的几种方法 字符串资源的定义 文件路径:res/values/strings.xml 字符串资源定义示例: <?xml version="1.0&q ...
- Android学习链接大放送
虽然贴链接这种事情..真是一种很偷懒的做法... 但是我一个小菜鸟,果断还是要以多向别人学习为主... 好资源要和大家分享对不对! 况且..放博客里..比收藏夹的利用几率要大一点! 原作者应该也很喜欢 ...
- ANDROID内存优化(大汇总——全)
写在最前: 本文的思路主要借鉴了2014年AnDevCon开发者大会的一个演讲PPT,加上把网上搜集的各种内存零散知识点进行汇总.挑选.简化后整理而成. 所以我将本文定义为一个工具类的文章,如果你在A ...
随机推荐
- 转@OneToMany或@ManyToOne的用法-annotation关系映射篇(上)
原文:http://blog.sina.com.cn/s/blog_6fef491d0100obdm.html 例如我们用一个例子来开启JPA的一对多和多对一的学习. 比如你去当当网上买书籍,当当网就 ...
- sqlldr
1.字符集 sqlldr可以指定读取的文件的字符集,如果数据库为gbk,读取的文件为utf-8,这个时候就需要指定字符集 load data CHARACTERSET 'UTF8' 2.sqlldr导 ...
- 移动端网页fixed布局问题解决方案
问题说明 移动端web的footer常常设计为fixed布局,但是在页面键盘被拉起时fixed的布局会出现问题,自己试了下,在较低版本ios和部分安卓机上会有此问题.具体问题看图示: <body ...
- java的向上转型总结
在<think of java>中对'向上转型'有着如下的描述 看完之后很蒙圈,所以自己在网上找了一些描述,并自己做了简单的总结 简单的例子 class A{ public void A1 ...
- SetTimer 与 回调函数
在控制台应用程序中,SetTimer的函数原型为: UINT_PTR SetTimer( HWND hWnd, // handle to window UINT_PTR nIDEvent, // ti ...
- 【ORM】--FluentNHibernate之基本映射详解
最近在做项目的时候用到了NHibernate,使用它并不困难,但是很麻烦.如果我的数据库有几百张表如果想要一个个的映射岂不是很麻烦,所以这种情况下使用NHibernate就会很笨重,虽然 ...
- Entity Framework技术导游系列 开篇 (转)
在微软平台写程序有年头了,随着微软数据存取技术的持续演化,我在程序中先后使用过ODBC.DAO.ADO.ADO.NET.LINQ to SQL. Entity Framework这些技术. 近几年来, ...
- python基础知识9——模块2——常见内置模块
内置模块 内置模块是Python自带的功能,在使用内置模块相应的功能时,需要[先导入]再[使用] 1.sys 用于提供对Python解释器相关的操作: sys.argv 命令行参数List,第一个元素 ...
- 使用Axis2实现WebService的发布和调用
一.Axis2的下载和安装 1.可从http://ws.apache.org/axis2/ 下载Axis2的最新版本: 可以下载如下三个zip包: axis2-1.7.3-bin.zip(用 ...
- love easily fade
Ubuntu addict and loving it , the answerer 's intro attracted me.When I first read a book on linux ...