安卓杂记(二)利用FrameLayout叠加多种view的方法
2015-01-27 13:12
363 查看
一.FrameLayout介绍:
FrameLayout是五大布局中最简单的一个布局,在这个布局中,整个界面被当成一块空白备用区域,所有的子元素都不能被指定放置的位置,它们统统放于这块区域的左上角,并且后面的子元素直接覆盖在前面的子元素之上,将前面的子元素部分和全部遮挡。1.在FrameLayout中添加普通的View
在FrameLayout中可以添加诸如imageView和TextView这样简单的View,它们层层向上叠加,上层遮蔽下层,代码示例如下:<?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/image1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:src="@drawable/sky"/> <ImageView android:id="@+id/image2" android:layout_width="fill_parent" android:layout_height="fill_parent" android:src="@drawable/cloud"/> <ImageView android:id="@+id/image3" android:layout_width="fill_parent" android:layout_height="fill_parent" android:src="@drawable/sun"/> </FrameLayout>图片层层叠加,只显示上层图片
2.在FrameLayout中利用<include>标签添加自定义的xml文件
<FrameLayout android:id="@+id/circleView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" >
<includelayout="@layout/circle_view"/>
<include
layout="@layout/circle_view2"/>
</FrameLayout>
3.在FrameLayout中引用自定义的view类文件
<FrameLayout android:id="@+id/circleView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" >
<com.example.viewflipperdemoactivity.CircleViewandroid:layout_width="fill_parent"android:layout_height="fill_parent"/> <TextView android:layout_width="fill_parent" />
</FrameLayout>
二.设置FrameLayout中的某个View透明
由于FrameLayout层层叠加的特性,使得下层View被上层View遮蔽,有时为了让下层View可见,就不得不让上层View透明:View.getBackground().setAlpha(100);
相关文章推荐
- 安卓杂记(二)利用FrameLayout叠加多种view的方法
- Visual C++中Tab View的多种实现方法
- iPhone 上利用MKMapView实现简单地图的方法
- TextView的字体颜色设置的多种方法
- 安卓WebView中接口隐患(远程代码执行漏洞)与手机挂马利用
- 利用FrameLayout连接一组view实现流畅的左右滑动
- ASP.NET基础教程-利用Find()方法寻找DataRowView的索引值
- 安卓ViewPager控件的使用方法
- 安卓:Webview不弹出输入法的解决方法
- android TextView的字体颜色设置的多种方法
- video标签在安卓webview下无法自动播放问题的解决方法
- iPhone 上利用MKMapView实现简单地图的方法
- android利用WebView与JavaScript交互的方法
- Tab View的多种实现方法 .
- android TextView的字体颜色设置的多种方法(转)
- 利用InstallShield12制作安装包之三:判断操作系统类型的多种方法
- Android中级教程之(四)----->页面的转换,利用setContentView方法
- android TextView的字体颜色设置的多种方法
- 安卓WebView中接口隐患与手机挂马利用(远程命令执行)
- Fabric.js 在安卓webview下重复绘制的解决方法