android framelayout 应用

有关FrameLayout的翻译,一直都有争议,从习惯来看,Frame应为框架,但这里若以框架概之,显得有些不妥,因此我参考了“单帧布局”这一翻译。

  单帧布局尤为简单,这种布局下每个添加的子控件都被放在布局的左上角,并覆盖在前一子控件的上层。看下面这个例子:

  < ?xml version="1.0" encoding="utf-8"? >

  < FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"

  android:layout_width="fill_parent"

  android:layout_height="fill_parent" >

  < TextView

  android:text="big"

  android:layout_width="wrap_content"

  android:layout_height="wrap_content"

  android:textSize="50pt"/ >

  < TextView

  android:text="middle"

  android:layout_width="wrap_content"

  android:layout_height="wrap_content"

  android:textSize="20pt"/ >

  < TextView

  android:text="small"

  android:layout_width="wrap_content"

  android:layout_height="wrap_content"

  android:textSize="10pt"/ >

  < /FrameLayout >

  这里从底层到外层依次放了三个单词:big(50pt)、middle(20pt)、small(10pt),效果如下:

  需要注意的是,当我们使用ImageView显示图片时,应当用android:src指定要显示的图片,而非android:background.

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值