您的位置:首页 > 移动开发 > Android开发

Android开发总结笔记 FrameLayout(帧布局) 1-1-3

2015-09-22 08:26 344 查看
FrameLayout的继承结构





帧布局的主要作用是,后面添加的组件会覆盖前面添加的组件。(FrameLayout
API)

帧布局中的xml属性





通常用法

<FrameLayoutxmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="300dp"
android:layout_height="300dp"
android:background="@android:color/holo_blue_bright"/>
<ImageView
android:layout_width="200dp"
android:layout_height="200dp"
android:background="@android:color/holo_green_dark"/>
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:background="@android:color/holo_orange_dark"/>
</FrameLayout>


效果图





现在加上android:foreground这个属性试试

android:foreground="@mipmap/ic_launcher"






==。好大,应该是framelayout高和宽都设置了match_parent的关系

下面再来看看加上android:foregroundGravity试试

android:foregroundGravity="bottom"






嗯。这大小是正常点了。

FrameLayout总的用法还是比较简单的。就这么两个属性

其他

在关于FrameLayout的API文档中,前面部分有一个setConsiderGoneChildrenWhenMeasure()的方法

如果设置为true,在测量子组件的时候就会考虑把带有android:visibility一起测量,false则忽略,默认为false
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: