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>

代码示例

最新文章

  1. 怎么找到苹果App Store的应用程序下载链接地址
  2. copy-paste component
  3. 学习WebSocket(二):使用Spring WebSocket做一个简单聊天室
  4. 【131202】SQL
  5. java如何得到GET和POST请求URL和参数列表(转)
  6. C++ 多态的实现原理与内存模型
  7. appium跑demo简单实例讲解
  8. python中的类,对象,方法,属性等介绍
  9. ANT编译build.xml
  10. Unity3d:Unknown type &#39;System.Collections.Generic.CollectionDebuggerView&#39;1
  11. MySQL5.7.12新密码登录方式及密码策略
  12. Java中final、finally和finalize的区别(转)
  13. LINUX怎么修改IP地址
  14. 使用cl编译C/C++
  15. SparkSQL
  16. Python多版本共存(生产环境)
  17. 基于UML的高校教务管理系统的设计与实现
  18. java发送邮件高级篇
  19. 创建servlet程序知识点详解---servlet-day12
  20. CSDN 个性 博客 栏目 自定义 栏目 酷炫 音乐 视频

热门文章

  1. VS2017 下使用 git. git服务器使用gitblit
  2. CNN学习笔记:梯度下降法
  3. hadoop nn 运维一例
  4. Atom常用快捷键及设置
  5. h5打开App的方法。
  6. ng-click得到当前元素,
  7. 一种BIM缺失多态性介导的酪氨酸激酶抑制剂的耐药性
  8. 20145201《Java程序设计》第1次实验报告
  9. Gradle 引入本地定制 jar 包,而不使用坐标下载 jar 包的方法
  10. web页面如何打包封闭成手机APP