1.LinearLayout(线性布局)
  android:orientation="vertical" //布局
  android:layout_width="wrap_content" //控件宽度
  android:layout_height="fill_parent" //控件高度
  android:layout_weight //可以指定每个控件所占的比例
  注意:"vertical":垂直布局 "horizontal":水平布局
      wrap_content:宽度/高度和内容的宽度/高度相同
      fill_parent:宽度/高度是整个父组件的宽度和高度

 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:id="@+id/ete1"
android:layout_width="100px"
android:layout_height="100px"
android:background="#00FF00"
/>
<TextView
android:id="@+id/bte1"
android:layout_width="80px"
android:layout_height="80px"
android:background="#0000FF"
/>
<TextView
android:id="@+id/tve1"
android:layout_width="60px"
android:layout_height="60px"
android:background="#FF0000"
/>
</LinearLayout>

代码示例

2.FrameLayout(帧布局)
    叠加效果

 <?xml version="1.0" encoding="utf-8"?>
<!-- "vertical":垂直布局 "horizontal":水平布局 -->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="100px"
android:layout_height="100px"
android:background="#FF0000"
/>
<TextView
android:layout_width="80px"
android:layout_height="80px"
android:background="#00FF00"
/>
<TextView
android:layout_width="60px"
android:layout_height="60px"
android:background="#0000FF"
/>
</FrameLayout>

代码示例

3.Relativelayout(相对布局)
  android:layout_below //在某个组件的下面
  android:layout_toLeftOf //在某个组件的左边
  android:layout_toRinghtOf //在某个组件的右边
  android:layout_alignTop //在某个组件上对齐
  android:layout_alignBottom //在某个组件下对齐
  android:layout_alignLeft //在某个组件左对齐
  android:layout_alignRight //在某个组件右对齐

 <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:id="@+id/tvr1"
android:layout_width="100px"
android:layout_height="100px"
android:background="#FF0000"
/>
<TextView
android:id="@+id/tvr2"
android:layout_width="80px"
android:layout_height="80px"
android:background="#00FF00"
android:layout_below="@+id/tvr1"
/>
<TextView
android:id="@+id/tvr3"
android:layout_width="60px"
android:layout_height="60px"
android:background="#0000FF"
android:layout_alignRight="@+id/tvr1"
/>
</RelativeLayout>

代码示例

4.TableLayout(表格布局)
  注意:表格布局的组件要放在TableRow中

 <?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
> <TableRow>
<TextView
android:layout_width="100px"
android:layout_height="100px"
android:background="#FF0000"
/>
</TableRow>
<TableRow>
<TextView
android:layout_width="80px"
android:layout_height="80px"
android:background="#00FF00"
/>
<TextView
android:layout_width="60px"
android:layout_height="60px"
android:background="#0000FF"
/>
</TableRow>
</TableLayout>

代码示例

5.AbsoluteLayout(绝对布局)
  android:layout_x="80px" //x轴坐标值
  android:layout_y="20px" //y轴坐标值

 <?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:id="@+id/tvr1"
android:layout_width="100px"
android:layout_height="100px"
android:background="#FF0000"
/>
<TextView
android:layout_x="60px"
android:layout_y="10px"
android:id="@+id/tvr2"
android:layout_width="80px"
android:layout_height="80px"
android:background="#00FF00"
android:layout_below="@+id/tvr1"
/>
<TextView
android:layout_x="80px"
android:layout_y="20px"
android:id="@+id/tvr3"
android:layout_width="60px"
android:layout_height="60px"
android:background="#0000FF"
android:layout_alignRight="@+id/tvr1"
/>
</AbsoluteLayout>

代码示例

Android的布局方式的更多相关文章

  1. 【深入篇】Android常用布局方式简介

    LinearLayout 线性布局是程序中最常见的布局方式.一般分为水平线性布局和竖直线性布局,通过android.orientation属性可以设置线性布局的方向. 在布局中操作颜色时,要用的是十六 ...

  2. Android常规布局方式和方法

    一.关于给控件添加ID属性 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xm ...

  3. android layout布局属性

    参考:http://blog.csdn.net/msmile_my/article/details/9018775 第一类:属性值 true或者 false           android:lay ...

  4. Android layout 布局 属性详解

    第一类:属性值 true或者 false           android:layout_centerHrizontal 水平居中     android:layout_centerVertical ...

  5. Android开发之基本控件和详解四种布局方式

    Android中的控件的使用方式和iOS中控件的使用方式基本相同,都是事件驱动.给控件添加事件也有接口回调和委托代理的方式.今天这篇博客就总结一下Android中常用的基本控件以及布局方式.说到布局方 ...

  6. Android入门(十):界面的布局方式及其实际应用

    关于Android界面布局,网上已经有了很多非常不错的学习资料,在这里我也不班门弄斧了,推荐两篇我认为写的不错的教程,然后再重点讲一下几种布局方式的实际应用. 教程链接:①http://www.cnb ...

  7. 【Android UI】Android开发之View的几种布局方式及实践

    引言 通过前面两篇: Android 开发之旅:又见Hello World! Android 开发之旅:深入分析布局文件&又是“Hello World!” 我们对Android应用程序运行原理 ...

  8. Android 开发之旅:view的几种布局方式及实践

    本文的主要内容就是分别介绍以上视图的七种布局显示方式效果及实现,大纲如下: 1.View布局概述 2.线性布局(Linear Layout) 2.1.Tips:android:layout_weigh ...

  9. Android 开发:view的几种布局方式及实践

    View的几种布局显示方法,以后就不会在针对布局方面做过多的介绍.View的布局显示方式有下面几种:线性布局(Linear Layout).相对布局(Relative Layout).表格布局(Tab ...

随机推荐

  1. 为Eclipse指定JVM

    运行eclipse时,报如下错误时,可以通过修改配置文件eclipse.ini来解决. Version 1.4.1_01 of the JVM is not suitable for this pro ...

  2. Java并发(4):ThreadLocal

    一.对ThreadLocal的理解 ThreadLocal是java.lang包中的一个类,很多地方叫做线程本地变量,也有些地方叫做线程本地存储,其实意思差不多.可能很多朋友都知道ThreadLoca ...

  3. Java应用程序连接数据库--JDBC基础

    Java应用程序连接数据库--JDBC基础   Java应用程序连接数据库–JDBC基础 <!-- MySQL驱动,连接数据库用,由数据库厂商提供 --> <dependency&g ...

  4. 8月自动化测试课程 - Selenium开源自动化测试实践

    8月自动化测试课程 - Selenium开源自动化测试实践 http://gdtesting.cn/news.php?id=35

  5. Bootstrap总结一

    参考我的博客:http://www.isedwardtang.com/2017/08/30/bootstrap-primer-1/

  6. Leaflet API 翻译(一)

    摘自:http://jsrookie.iteye.com/blog/2318972 L.Map API各种类中的核心部分,用来在页面中创建地图并操纵地图. Constructor(构造器) 通过div ...

  7. 禁止电脑登陆QQ聊天系统的四种方法

    一.使用防火墙禁止端口法 QQ使用的默认端口是 UDP 4000,使用防火墙将该端口关闭,那么别人就不能使用QQ了,当自己需要上网时只需开放该端口就可以了. 下面以我使用的“金山网镖6”进行说明,点击 ...

  8. jQuery/CSS3 3D焦点图动画

    在线演示 本地下载

  9. 字符串的hash匹配

    如果要比较字符串是否相等,首先想到的是KMP算法,但是hash更加简洁易于编写,hash的目的是把一串字符转化成一个数字,用数字来比较是否相等.我让mod=912837417 Base=127,防止h ...

  10. 配置iptables实现本地端口转发的方法详解

    场景假如你在用 resin 调试一个 Web 程序,需要频繁地重启 resin.这个 Web 程序需要开在 80 端口上,而 Linux 限制 1024 以下的端口必须有 root 权限才能开启.但是 ...