墙纸设置的例子,还涉及一些图片变换的内容
取得当前墙纸
final WallpaperManager wallpaperManager = WallpaperManager.getInstance(this);
final Drawable wallpaperDrawable = wallpaperManager.getDrawable();
将墙纸设置到imageview上
imageView.setDrawingCacheEnabled(true);
imageView.setImageDrawable(wallpaperDrawable);
因为要对图片进行一些处理,所以打开了catch
imageView.setDrawingCacheEnabled(true)
点击Randomize按钮时,会随机生成一个数字,然后从预定义的数据中取出颜色
int mColor = (int) Math.floor(Math.random() * mColors.length);
然后将颜色覆盖在图片上,只允许某些颜色通过。
wallpaperDrawable.setColorFilter(mColors[mColor], PorterDuff.Mode.MULTIPLY);
mColors是一个数据,预先定义了一些颜色
final static private int[] mColors =
{Color.BLUE, Color.GREEN, Color.RED, Color.LTGRAY, Color.MAGENTA, Color.CYAN,
Color.YELLOW, Color.WHITE};
用户点击 Set Wallpaper按钮后,将新墙纸设置到系统中
wallpaperManager.setBitmap(imageView.getDrawingCache());
效果如下
分享到:
相关推荐
Android ApiDemos apk, 包括Android presentation双屏异显 demon, App>Activity>Presentation
最新Android apidemos
API Demos 是 Google 为了 Android 开发者所提供的一个 Android API 合集,其中包含了很多的 API 范例,同时遵循了良好的代码规范,是一个值得开发者研究和学习的典型。android的ApiDemos,需要解压缩后使用。
android APIdemos,android 源码简单使用demos
该Api Demos 源码是基于Android6.0 ,Eclipse下的,可以直接使用Android studio 导入工程即可。
最新版ApiDemos Android SDK 中带有很多例子,其中ApiDemo 详细介绍了Android 平台主要API,分成了 · App · Content · Graphics · Media · OS · Text · Views 几个大类,每个大类又分为几个小类,...
Android官网ApiDemos源码 供大家学习参考之用
ApiDemos 6.0
Android API 19 的API DEMOS 对应安卓版本4.4.2
Android 5.1的ApiDemos安装包
Android2.2 ApiDemos Android2.2 ApiDemos Android2.2 ApiDemos
android api19 ApiDemos .
Android ApiDemos2.1版本,sdk自带的sample。
android apidemos代码的示例解析,讲的挺全的
从官方预览包里提取的Android6.0 ApiDemos.apk,方便安装在真机上查看实例的实际效果。
漂亮的个人网站界面,演示地址:http://rbista.com/demos/zwin/ 解压密码:http://rbista.com/demos/zwin/
android ApiDemos 不报错版本,虚拟机和真机都可以完美运行,里面包含android所有的控件和优美的编码风格。对初中高级工程师很有帮助
android ApiDemos里的Transition3d翻转修复完善 博文在http://blog.csdn.net/ethan_xue/article/details/8022471