android 磨砂玻璃效果
2015-08-04 19:23
615 查看
今天工作中需要磨砂玻璃效果,就从网上查找一番,最后查找适合自己的,我的apk版本是android4.4的,所以就下了一个方法
代码如下:
1.磨砂效果方法
2.添加到布局背景中
这里mLauncher 代表Context,
draw_id 代表图片id ,
12代表radius ,radius范围0-25之间
代码如下:
1.磨砂效果方法
@SuppressLint("InlinedApi") public static Bitmap fastblur(Context context, Bitmap sentBitmap, int radius) { Bitmap bitmap = sentBitmap.copy(sentBitmap.getConfig(), true); final RenderScript rs = RenderScript.create(context); final Allocation input = Allocation.createFromBitmap(rs,sentBitmap, Allocation.MipmapControl.MIPMAP_NONE,Allocation.USAGE_SCRIPT); final Allocation output = Allocation.createTyped(rs,input.getType()); final ScriptIntrinsicBlur script = ScriptIntrinsicBlur.create(rs,Element.U8_4(rs)); script.setRadius(radius);/* e.g. 3.f */ script.setInput(input); script.forEach(output); output.copyTo(bitmap); return bitmap; }
2.添加到布局背景中
mLaybg.setBackground(new BitmapDrawable(fastblur(mLauncher,BitmapFactory.decodeResource(getResources(),draw_id),12)));
这里mLauncher 代表Context,
draw_id 代表图片id ,
12代表radius ,radius范围0-25之间
相关文章推荐
- android "receiver not registered"
- 解决Android 5.0中出现的警告:Service Intent must be explicit
- Android.mk 文件语法规范
- Android 自定义Spinner
- Android——APK 在32bit/64bit平台 动态库问题
- IDA来Patch android的so文件
- IDA在内存中dump出android的Dex文件
- Android L metral design风格之CardView
- Ida动态修改android程序的内存数据和寄存器数值,绕过so文件的判断语句
- Ida双开定位android so文件
- Android中不同包路径下Activity跳转的实现(解决ActivityNotFoundException)
- IDA调试android so文件.init_array和JNI_OnLoad
- android 中Activity在程序运行过程中进入全屏和退出全屏
- Android之Adapter总结
- android检查版本更新实现思路
- android中sharedpreference封装思路
- android两种没接触过的api获取方法
- Android 目标平台版本应该大于或等于 10(The android-platform should be equal/large than 10)
- Android.mk编译APK范例
- 在android系统中添加hello程序