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 ...
随机推荐
- Android test---CTS
转载 1.下载最新的CTS download 2.准备工作 3.启动CTS测试 3.1 在控制台进入目录android-cts,目录android-cts下有三个文件夹,其中一个是tools. 3.2 ...
- Android test---robotium----简单例子
1.首先新建一个要被测试的工程,命名为”robotium“:一个很简单的Android 应用程序:主页面只有个 TextView 控件: 2. 在建一个用于测试的工程 ,命名为”robotiumTes ...
- go语言环境搭建+sublime text3(windows环境下)
感觉有点坑,整了一下午~搞定 go语言环境搭建+sublime text3(windows环境下) 1.安装sublime text3 2.安装go语言程序包 3.测试go语言是否安装成功 键 ...
- ReactJS学习笔记(二)
1.Ajax: componentDidMount 方法设置 Ajax 请求,等到请求成功,再用 this.setState 方法重新渲染 UI. /*demo1*/ var Demo1Box=Rea ...
- springmvc+mybatis整合
maven 依赖 <!-- springmvc --> <dependency> <groupId>org.springframework</groupId& ...
- 几种方法实现ajax请求内容时使用浏览器后退和前进功能
ajax是一个非常好玩的小东西,不过用起来也会存在一些问题. 我们可以利用ajax进行无刷新改变文档内容,但是没办法去修改URL,即无法实现浏览器的前进与后退.书签的收藏功能. 利用location的 ...
- Application、 session、iewstate,以及repeater 的commang用法
Session:在不同的浏览器之间传值,像银行之类的网站为了安全把用户名密码保存在session里面.每一台电脑访问服务器,都会是独立的一套session,key值都一样,但是内容都是不一样的 以 ...
- AES加密补位填充的一个问题
AES加密支持多种填充方式,NoPadding,PKCS5Padding,ISO10126Padding,ZerosPadding,PKCS7Padding. 其中PKCS7Padding 就是数据个 ...
- Ubuntu 14.10安装SecureCRT 7.3(转)
原文 :http://blog.csdn.net/chszs/article/details/40623169 1.软件准备 Ubuntu14.04 x64 下载SecureCRT7.3的版本:scr ...
- REST及RESTful的实现
什么是REST? REST (REpresentation State Transfer) 描述了一个架构样式的网络系统,比如 web 应用程序.它首次出现在 2000 年 Roy Fielding ...