android线性布局LinearLayout实例源代码

android源代码之线性布局LinearLayout

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

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

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

  <LinearLayout xmlns:android=”http://android.9tech.cn/”

  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>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值