布局

组件按照布局的要求依次排列,就组成了用户所看见的界面。Android的五大布局分别是LinearLayout(线性布局)、FrameLayout(单帧布局)、RelativeLayout(相对布局)、AbsoluteLayout(绝对布局)和TableLayout(表格布局)。

一、LinearLayout(线性布局)、FrameLayout(单帧布局)

 1 <?xml version="1.0" encoding="utf-8"?>
2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 android:orientation="vertical"
4 android:layout_width="fill_parent"
5 android:layout_height="fill_parent"
6 >
7 <!--
8 首先是线性布局这里面每一个元素跟在另一个元素的后面。可参考下列设置!主要是android:layout_weight="1"管用了
9 -->
10 <LinearLayout
11 android:orientation="horizontal"
12 android:layout_width="fill_parent"
13 android:layout_height="wrap_content"
14 >
15 <TextView
16 android:layout_width="fill_parent"
17 android:layout_height="wrap_content"
18 android:layout_weight="1"
19 android:background="#EFDAB8"
20 />
21 <TextView
22 android:layout_width="fill_parent"
23 android:layout_height="wrap_content"
24 android:layout_weight="1"
25 android:background="#FBAFF5"
26 />
27 </LinearLayout>
28 <LinearLayout
29 android:orientation="horizontal"
30 android:layout_width="fill_parent"
31 android:layout_height="wrap_content"
32 >
33 <TextView
34 android:layout_width="fill_parent"
35 android:layout_height="wrap_content"
36 android:layout_weight="2"
37 android:background="#EFDAB8"
38 />
39 <TextView
40 android:layout_width="fill_parent"
41 android:layout_height="wrap_content"
42 android:layout_weight="1"
43 android:background="#FBAFF5"
44 />
45 </LinearLayout>
46 <!--
47 FrameLayout布局就是单帧布局 FrameLayout是五大布局中最简单的一个布局,
48 在这个布局中,整个界面被当成一块空白备用区域,所有的子元素都不能被指定放置
49 的位置,它们统统放于这块区域的左上角,并且后面的子元素直接覆盖在前面的子元
50 素之上,将前面的子元素部分和全部遮挡。例子如下
51 -->
52 <FrameLayout
53 android:layout_width="fill_parent"
54 android:layout_height="fill_parent"
55 android:background="#525252"
56 >
57 <TextView
58 android:layout_width="fill_parent"
59 android:layout_height="fill_parent"
60 android:background="#644121"
61 />
62 <TextView
63 android:layout_width="wrap_content"
64 android:layout_height="wrap_content"
65 android:background="#B5D556"
66 android:text="你好我的世界!"
67 android:textSize="24sp"
68 android:textColor="#F56700"
69 />
70 </FrameLayout>
71 </LinearLayout>


更多相关文章

  1. 用LinearLayout和RelativeLayout分别实现两端对齐
  2. android 界面布局
  3. android 界面布局 很好的一篇总结
  4. android布局 LinearLayout和RelativeLayout
  5. android shape 使用小结
  6. Android布局文件属性
  7. android 界面布局 很好的一篇总结 【转】
  8. 让editView、AutoCompleteTextView开始捕获的焦点
  9. android 界面布局 很好的一篇总结 【转】

随机推荐

  1. Android中从图库中选取图片实例详解
  2. Android中给webview设置代理
  3. Android Data Backup
  4. Android原生拼音输入法分析
  5. 修改android开机logo
  6. Android查询不到电话号码解决方法
  7. imageView的Selector图片选择问题
  8. Android 唯一标识获取
  9. AndroidStudio使用JNI教程
  10. 【Android导航决 君子生非异也 善假于物