WEB开发网      婵傜晫鐝總钘夊瀻娴滎偓绱掓担鐘垫畱娑撯偓娴犺棄鍨庢禍顐fЦ閹存垳婊戦惃鍕娴犺棄濮╅崝娑崇幢鐠囧嘲鍨庢禍锟� ---閿曪拷
开发学院手机开发Android 开发 Android布局之FrameLayout(单帧布局) 阅读

Android布局之FrameLayout(单帧布局)

 2010-06-17 03:22:00 来源:WEB开发网 閵嗭拷閸戝繐鐨€涙ぞ缍�婢х偛銇囩€涙ぞ缍�閵嗭拷  閸忚櫕鏁炴Λ娆愬盁閸楀洨娈戝顔煎触
核心提示:有关FrameLayout的翻译,一直都有争议,Android布局之FrameLayout(单帧布局),从习惯来看,Frame应为框架,效果如下:需要注意的是,当我们使用ImageView显示图片时,但这里若以框架概之,显得有些不妥

有关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.

Tags:Android 布局 FrameLayout

编辑录入:coldstar [复制链接] [打 印]
赞助商链接