在andriod里实现透明遮罩效果
2014-01-07 14:37
190 查看
一,在android里实现遮罩效果的思路:
在aa里用bb把cc屏蔽掉(遮罩)。
二,实现过程以及原理:
1,使用FrameLayout的特性
整个界面被当成一块空白备用区域,所有的子元素都不能被指定放置的位置,
它们统统放于这块区域的左上角,并且后面的子元素直接覆盖在前面的子元素之上,
将前面的子元素部分和全部遮挡。
2,用ps制作就张透明图片,最好用android里的drawable让图片平铺 android:tileMode="repeat"
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/zhezhao"
android:tileMode="repeat"
/>
3,使用View的addView(aa.addView(bb);)或者setVisibility(bb.setVisibility(0);)
如果你选择的是addView那么你要findViewById找到在什么地方实现遮罩;
如果你选择的是setVisibility那么你要findViewById找到用什么实现遮罩;
注意:aa一定是FrameLayout
三,参看Layout文件
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/aa"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="@+id/bb"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
<ImageView
android:id="@+id/cc"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:src="@drawable/zhezhao2"
android:visibility="gone" >
</ImageView>
</FrameLayout>
God bless you
在aa里用bb把cc屏蔽掉(遮罩)。
二,实现过程以及原理:
1,使用FrameLayout的特性
整个界面被当成一块空白备用区域,所有的子元素都不能被指定放置的位置,
它们统统放于这块区域的左上角,并且后面的子元素直接覆盖在前面的子元素之上,
将前面的子元素部分和全部遮挡。
2,用ps制作就张透明图片,最好用android里的drawable让图片平铺 android:tileMode="repeat"
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/zhezhao"
android:tileMode="repeat"
/>
3,使用View的addView(aa.addView(bb);)或者setVisibility(bb.setVisibility(0);)
如果你选择的是addView那么你要findViewById找到在什么地方实现遮罩;
如果你选择的是setVisibility那么你要findViewById找到用什么实现遮罩;
注意:aa一定是FrameLayout
三,参看Layout文件
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/aa"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="@+id/bb"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
<ImageView
android:id="@+id/cc"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:src="@drawable/zhezhao2"
android:visibility="gone" >
</ImageView>
</FrameLayout>
God bless you
相关文章推荐
- JS+CSS实现弹出全屏灰黑色透明遮罩效果的方法
- 基于JavaScript实现全屏透明遮罩div层锁屏效果
- JS+CSS实现弹出全屏灰黑色透明遮罩效果的方法
- 实现弹出一个全屏灰黑色透明遮罩效果
- 基于JavaScript实现全屏透明遮罩div层锁屏效果
- Activity实现透明效果
- 【jQuery】遮罩效果的实现
- 学习笔记3--CSS制作鼠标放上后淡入透明遮罩层效果
- 微信小程序 利用css实现遮罩效果实例详解
- 遮罩clippingNode实现标题闪亮特效、类似机关枪瞄准效果、跑马灯效果
- css实现遮罩层(解决透明背景上的文字不透明)
- 【前端】CSS实现背景图片透明和文字不透明效果
- SWT实现的图片透明效果
- JFrame实现透明效果
- 窗口控件透明效果的实现--DSkinLite界面库使用技巧
- Axure实现弹框周围遮罩效果
- android 4.1.2 launcher2实现像4.4launcher3应用列表背景透明的效果
- iOS实现导航栏全透明效果
- iphone app 的图标上被自动添加一层半透明遮罩(玻璃效果),小米3这样的高分屏icon不生效,怎么破?
- 实现tabs组件IFrame模式的遮罩效果