Android03--Android之UI布局01FrameLayout
来源:互联网 发布:淘宝运营团队分工 编辑:程序博客网 时间:2024/06/09 20:37
学习安卓的第三天,今天来学习一下FrameLayout
我们使用布局方式时:如果能使用第三方的布局就是用第三方的布局;
1.认识FrameLayout(5.0之前)
在5.0之前,放置在FrameLayout中 控件,所有放在布局里的控件,都按照层次堆叠在屏幕的左上角。后加进来的控件覆盖前面的控件。
<TextView android:id="@+id/textview1" android:layout_width="300dp" android:layout_height="300dp" android:layout_gravity="center" android:background="#33ffff" /> <TextView android:id="@+id/textview2" android:layout_width="240dp" android:layout_height="240dp" android:layout_gravity="center" android:background="#FF33ccff" /> <TextView android:id="@+id/textview3" android:layout_width="180dp" android:layout_height="180dp" android:layout_gravity="center" android:background="#FF3399ff" /> <TextView android:id="@+id/textview4" android:layout_width="120dp" android:layout_height="120dp" android:layout_gravity="center" android:background="#FF3366ff" /> <TextView android:id="@+id/textview5" android:layout_width="60dp" android:layout_height="60dp" android:layout_gravity="center" android:background="#FF3300ff" />
默认会将控件放置在左上角,但是我们也可以通过layout_gravity属性和gravity属性指定到其他位置; (注意textView的宽高是否wrap-content)
常用属性:(但这个并不打破FrameLayout的布局特性,如果有多个水下TextView,他还是会叠加放置的.)
<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:textColor="#f00" android:textSize="30dp" android:layout_gravity="center" android:text="Hello World!" />
<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:textColor="#f00" android:textSize="30dp" android:gravity="center" android:text="Hello World!" />
常用的两个属性:
android:foreground:设置该帧布局容器的前景图像android:foregroundGravity:设置前景图像显示的位置
前景图像是什么?
答:永远处于帧布局最上面,直接面对用户的图像,就是永远不会被覆盖的图像;
5.0之后
5.0之前和5.0之后的区别:
所以在5.0之后,就不一定都是后写的textView覆盖前些的TextView,现在的情况就是:
比如桌子上面好几张卡片,谁离桌面的距离越高,谁就在上面(出现Z轴的概念,)
// 控件离开屏幕的高度(一般小于10dp),两个属性同样的效果,默认是0dp android:elevation="5dp" android:translationZ="5dp"
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="第一层" android:textColor="#f00" android:translationZ="10dp" android:textSize="80sp" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="第二层" android:textColor="#785a5a" android:textSize="60sp" />
效果:
我们会看到一个阴影,并且第一层会在第二层之上.
应用:
1.FrameLayout这种布局很不灵活,用处很少.
2.在API12之后,出现了FrameLayout(碎片),在定义区域的时候,会使用到FrameLayout,因为FrameLayout是ViewGroup中消耗资源最少的一个布局.
0 0
- Android03--Android之UI布局01FrameLayout
- Android03--Android之UI布局02RelativeLayout
- Android03--Android03之UI布局03LinearLayout
- Android UI布局之FrameLayout
- Android UI之FrameLayout(帧布局)
- Android UI 之FrameLayout(-)
- Android布局之FrameLayout
- Android之FrameLayout布局
- Android-布局之FrameLayout
- android 开发布局之FrameLayout
- android布局方式之FrameLayout
- Android之FrameLayout(帧布局)
- Android之FrameLayout(帧布局)
- 《详解Android四大布局》之FrameLayout布局
- 【转载】Android布局讲解之FrameLayout布局
- New UI-布局之FrameLayout(帧布局)详解
- Android UI界面之FrameLayout(了解)
- Android 布局 之 TableLayout,RelativeLayout,AbsoluteLayout,FrameLayout
- java将字节转换成十六进制输出
- Leetcode39:Combination Sum
- Cocos2d-x Lua学习笔记
- 创建Android新工程时,丢失MainActivity.java文件,丢失R.java文件,values/values-v11/values-v14 styles.xml文件出错
- 提高情商的八种方法
- Android03--Android之UI布局01FrameLayout
- textView取消回车换行
- HTTP 协议详解
- 基于Nginx,搭建HLS(HTTP Live Streaming)server,点播&直播
- VMware中CentOS7连接外网
- 策略模式
- split-huge-file
- gulp yargs | uglify | less | livereload | sourcemaps | rename |clean-css 综合应用
- 找女朋友