简单来说:FrameLayout中的子元素总是以屏幕的左上角层叠在一起。
事实上,这是不确切的,我们可以对子元素添加android:layout_gravity属性来设置他们的位置的。
比如,下面的布局子控件都在什么位置呢?
<?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">
<ImageView
android:id="@+id/image"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="center"
android:src="@drawable/candle" />
<TextView
android:id="@+id/text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textColor="#00ff00"
android:text="@string/hello" />
<Button
android:id="@+id/start"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:text="Start" />
</FrameLayout>
在FrameLayout布局里面android:layout_margin的各种属性必须依赖于android:layout_gravity,也就是说,要想margin生效,必须设定view的layout_gravity属性。单独设置marginLeft等属性是无效的。
分享到:
相关推荐
android demo,FrameLayout的使用,该实例实现了一个美女在地图上的行走。
Android Framelayout显示静态和动态的扑克牌 包含Handler 和Timer TimerTask的使用方法
Android中帧布局FrameLayout的常用属性.pdf 学习资料 复习资料 教学资源
Android项目仿新浪微博下拉刷新继承FrameLayout.rar
Android中使用FrameLayout布局完成教学案例的要求说明.pdf 学习资料 复习资料 教学资源
Android中使用FrameLayout布局完成教学案例的代码清单.pdf 学习资料 复习资料 教学资源
通过使用 FrameLayout 实现霓虹灯效果 在改变背景颜色时采用了逐级递增的方式,也就是说当前TextView的背景颜色 是上一次改变背景颜色时比当前TextView尺寸小的相邻的TextView的背景颜色。这样看起来像是某一种颜色...
Android中使用FrameLayout完成的图片浏览器练习题要求说明.pdf 学习资料 复习资料 教学资源
Android中使用FrameLayout完成的图片浏览器项目的代码清单.pdf 学习资料 复习资料 教学资源
模仿墨迹天气的天气展示, 使用FrameLayout实现 目的是通过此列子展示FrameLayout的使用
19Android-04-frameLayout.mp4
本示例通过使用 FrameLayout 实现霓虹灯效果 在改变背景颜色时采用了逐级递增的方式,也就是说当前TextView的背景颜色 是上一次改变背景颜色时比当前TextView尺寸小的相邻的TextView的背景颜色。这样看起来像是某...
使用FrameLayout帧布局实现tabhost的效果
ImageView和FrameLayout拥有手势控制和定位动画
高仿新浪微博,采用FrameLayout布局的形式来实现下拉刷新。 在原程序的基础上添加了下拉刷新后listview列表内容的更新,更好的模拟刷新后的效果。 程序已在模拟器中测试通过,且效果很好。
主要介绍了Android布局之FrameLayout帧布局的相关资料,需要的朋友可以参考下
Android中帧布局FrameLayout的特点.pdf 学习资料 复习资料 教学资源
本篇文章是对AnDroid FrameLayout的使用进行了详细的分析介绍,需要的朋友参考下
FrameLayout(帧布局)实现闪烁霓虹灯效果
FrameLayout 在这个布局中,所有的子元素都不能被指定放置的位置,他们统统防御这块区域的左上角, 并且后面的子元素直接覆盖在前面的子元素之上,将前面的子元素部分和全部遮挡。 用途 常用于进度条的表示 &...