Chinaunix首页 | 论坛 | 博客
  • 博客访问: 75138
  • 博文数量: 48
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 340
  • 用 户 组: 普通用户
  • 注册时间: 2013-12-30 14:22
文章分类

全部博文(48)

文章存档

2014年(47)

2013年(1)

我的朋友

分类: Android平台

2014-03-21 15:42:20

之线性布局LinearLayout

  线性布局是所有布局中最常用的类之一,也是RadioGroup, TabWidget, TableLayout, TableRow, ZoomControls类的父类。LinearLayout可以让它的子元素垂直或水平的方式排成一行(不设置方向的时候默认按照垂直方向排列)

  下面看一个LinearLayout的例子:别被例子的长度吓住,仔细看一下其实就是一个LinearLayout中放5TextView标签而已,TextView相当于Html标签中的Label

  <?xml version=”1.0″ encoding=”utf-8″?>

  <LinearLayout xmlns:android=””

  android:orientation=”vertical”

  android:layout_width=”fill_parent”

  android:layout_height=”fill_parent”

  android:gravity=”center_horizontal”

  >

  <TextView

  android:layout_width=”fill_parent”

  android:layout_height=”wrap_content”

  android:text=”给小宝宝起个名字:

  android:textSize=”20px”

  android:textColor=”#0ff”

  android:background=”#333″/>

  <TextView

  android:layout_width=”wrap_content”

  android:layout_height=”wrap_content”

  android:text=”遥遥是男孩的小名

  android:textSize=”20px”

  android:textColor=”#0f0″

  android:background=”#eee”

  android:layout_weight=”3″

  />

  <TextView

  android:layout_width=”wrap_content”

  android:layout_height=”wrap_content”

  android:text=”瑶瑶是女孩的小名

  android:textColor=”#00f”

  android:textSize=”20px”

  android:background=”#ccc”

  android:layout_weight=”1″

  />

  <TextView

  android:layout_width=”fill_parent”

  android:layout_height=”wrap_content”

  android:text=”海因是男孩的大名

  android:textColor=”#f33″

  android:textSize=”20px”

  android:background=”#888″

  android:layout_weight=”1″

  />

  <TextView

  android:layout_width=”fill_parent”

  android:layout_height=”wrap_content”

  android:text=”海音是女孩的大名

  android:textColor=”#ff3″

  android:textSize=”20px”

  android:background=”#333″

  android:layout_weight=”1″

  />

  </LinearLayout>

阅读(315) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~