android 布局api文档,Linear Layout

android:orientation 属性。

linearlayout.png

margin,每个子视图都有gravity。

Layout Weight

Equally weighted children

To create a linear layout in which each child uses the same amount of

space on the screen, set the android:layout_height of each view to "0dp" (for a

vertical layout) or the android:layout_width of each view to "0dp" (for a

horizontal

layout). Then set the android:layout_weight of each view to "1".

线性布局支持给个别的子视图设定权重,通过android:layout_weight属性。就一个视图在屏幕上占多大的空间而言,这个属性给其设定了一个重要的值。一个大的权重值,允许它扩大到填充父视图中的任何剩余空间。子视图可以指定一个权重值,然后视图组剩余的其他的空间将会分配给其声明权重的子视图。默认的权重是0.

例如,如果有三个文本框,其中两个声明的权重为1,另外一个没有权重,没有权重第三个文本字段不会增加,只会占用其内容所需的面积。其他两个同样的会扩大以填补剩余的空间,在三个文本域被测量后。如果第三个字段,然后给定的权重为2(而不是0),那么它现在的声明比其他的更重要,所以它得到一半的总的剩余空间,而前两个平均分配剩余的。

Example

sample-linearlayout.png

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:paddingLeft="16dp"

android:paddingRight="16dp"

android:orientation="vertical" >

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:hint="@string/to" />

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:hint="@string/subject" />

android:layout_width="fill_parent"

android:layout_height="0dp"

android:layout_weight="1"

android:gravity="top"

android:hint="@string/message" />

android:layout_width="100dp"

android:layout_height="wrap_content"

android:layout_gravity="right"

android:text="@string/send" />

For details about the attributes available to each child view of a

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值