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. Read Large Files in Python

    I have a large file ( ~4G) to process in Python. I wonder whether it is OK to "read" such ...

  2. Swap 2 Variables in Python

    In Python, it's concise, easy and faster to swap 2 variables compared in other Programming languages ...

  3. smarty内置函数

      1.{append} 追加 2.{assign} 赋值 3.{block} 块 4.{call} 调用 5.{capture}捕获 6.{config_load}用来从配置文件中加载config变 ...

  4. Django:学习笔记(3)——REST实现

    Django:学习笔记(3)——REST实现 了解REST风格 按照传统的开发方式,我们在实现CURD操作时,会写多个映射路径,比如对一本书的操作,我们会写多个URL,可能如下 web/deleteB ...

  5. CNN学习笔记:目标函数

    CNN学习笔记:目标函数 分类任务中的目标函数 目标函数,亦称损失函数或代价函数,是整个网络模型的指挥棒,通过样本的预测结果与真实标记产生的误差来反向传播指导网络参数学习和表示学习. 假设某分类任务共 ...

  6. Java技术学习路线

    转载 作者:David 链接:https://www.zhihu.com/question/25255189/answer/86898400来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商 ...

  7. 调试利器之tcpdump详解

    简介你执行 man tcpdump 命令,你会看到文档中对tcpdump的说明是“dump traffic on a network”.可见,tcpdump是一个根据使用者的定义对网络上的数据包进行截 ...

  8. SqlHelper简单实现(通过Expression和反射)2.特性和实体设计

    对于需求中的不要暴露DataTable或DataSet,我想到了设计中常用的对象:实体(Entity),通过实体将数据库中的字段封装成类,这样做不仅使代码更有可读性,维护起来也很方便.同时我自定义了一 ...

  9. 【Java Web】入门资源整理

    [网站] 1.Java Web Application Tutorial for Beginners - JournalDev Google top1 除Java Web还有很多其他教程 2.Intr ...

  10. Mybatis${}、#{}及使用#{}时指定jdbcType

    一.Mybatis 的Mapper.xml语句中parameterType向SQL语句传参有两种方式:#{}和${} 我们经常使用的是#{},一般解说是因为这种方式可以防止SQL注入,简单的说#{}这 ...