Launcher3桌面壁纸被拉伸模糊的修改
来源:互联网 发布:企业员工通信软件 编辑:程序博客网 时间:2024/05/29 08:43
最近很忙,记录一下,Launcher3壁纸的修改。免得忘记。花了我近半天的时间。
环境:RK3288 + AndroidLL
步骤:进入Launcher3,长按桌面空白部分,设置一个内置的壁纸。
现象:发现模糊了,因为被拉伸了。
第一篇这样的文章。讲下解决思路。
思路:这种一看就比较简单的问题。从UI入手。(适合经验不足的人)。问题不在Launcher3上,就在WallpaperManagerService上。从Launcher3入手。。。。。。。
通过字符串就可以找到layout: actionbar_set_wallpaper。。。
见代码WallpaperCropActivity.java中。
<strong>protected void init() { 。。。。。。 // Action bar // Show the custom action bar view final ActionBar actionBar = getActionBar(); actionBar.setCustomView(R.layout.actionbar_set_wallpaper); actionBar.getCustomView().setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { boolean finishActivityWhenDone = true; cropImageAndSetWallpaper(imageUri, null, finishActivityWhenDone); } }); 。。。。。。}</strong>
继续看cropImageAndSetWallpaper
<strong>protected void cropImageAndSetWallpaper( Resources res, int resId, final boolean finishActivityWhenDone) { // crop this image and scale it down to the default wallpaper size for // this device int rotation = getRotationFromExif(res, resId); Point inSize = mCropView.getSourceDimensions(); Point outSize = getDefaultWallpaperSize(getResources(), getWindowManager()); RectF crop = getMaxCropRect( inSize.x, inSize.y, outSize.x, outSize.y, false); Runnable onEndCrop = new Runnable() { public void run() { // Passing 0, 0 will cause launcher to revert to using the // default wallpaper size updateWallpaperDimensions(0, 0); if (finishActivityWhenDone) { setResult(Activity.RESULT_OK); finish(); } } }; BitmapCropTask cropTask = new BitmapCropTask(this, res, resId, crop, rotation, outSize.x, outSize.y, true, false, onEndCrop); cropTask.execute(); }</strong>
这里讲一下,BitmapCropTask是实际设置的地方。就不贴代码了。
这里的outSize才是被拉伸的关键点。这里肯定要查的。
后来发现打了log。发现确实尺寸跟实际的尺寸对不上号。
getDefaultWallpaperSize
看这段代码。
<strong>static protected Point getDefaultWallpaperSize(Resources res, WindowManager windowManager) { if (sDefaultWallpaperSize == null) { Point minDims = new Point(); Point maxDims = new Point(); windowManager.getDefaultDisplay().getCurrentSizeRange(minDims, maxDims); int maxDim = Math.max(maxDims.x, maxDims.y); int minDim = Math.max(minDims.x, minDims.y); if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) { Point realSize = new Point(); windowManager.getDefaultDisplay().getRealSize(realSize); maxDim = Math.max(realSize.x, realSize.y); minDim = Math.min(realSize.x, realSize.y); } // We need to ensure that there is enough extra space in the wallpaper // for the intended parallax effects final int defaultWidth, defaultHeight; if (isScreenLarge(res)) { defaultWidth = (int) (maxDim * wallpaperTravelToScreenWidthRatio(maxDim, minDim)); defaultHeight = maxDim; } else { defaultWidth = Math.max((int) (minDim * WALLPAPER_SCREENS_SPAN), maxDim); defaultHeight = maxDim; } sDefaultWallpaperSize = new Point(defaultWidth, defaultHeight); } return sDefaultWallpaperSize; }</strong>
看一下这里,打个log,发现defaultHeight和defaultWidth这两个值不对。尺寸很大。那肯定是妥妥的被拉伸了。符合对现象的分析。
修改方法:搞个真实的尺寸就搞定了
<strong> Point realSize = new Point(); windowManager.getDefaultDisplay().getRealSize(realSize); final int defaultWidth, defaultHeight; if (/*isScreenLarge(res)*/false) { defaultWidth = (int) (maxDim * wallpaperTravelToScreenWidthRatio(maxDim, minDim)); defaultHeight = maxDim; } else { //defaultWidth = Math.max((int) (minDim * WALLPAPER_SCREENS_SPAN), maxDim); //defaultHeight = maxDim; defaultWidth = realSize.x; defaultHeight = realSize.y; }</strong>
修改完毕。就这样。壁纸不被拉伸的话。就不需要继续看WallpaperManagerService了
小结。以前觉得很简单的代码,找到改了之后还是会忘。算了。还是记下来靠谱。。。
方案公司出来的人,没什么产品,也没什么代码,但是阅读framework阅读application阅读外文文档 的能力 还是有的。
0 0
- Launcher3桌面壁纸被拉伸模糊的修改
- Launcher3 桌面壁纸滑动
- Android Launcher3的自定义修改总结
- 修改Launcher3应用Icon的样式
- Launcher3常见定制修改
- Launcher3 定制修改
- 5.1 Launcher3 修改总结
- MFC使用IActiveDesktop修改桌面壁纸
- JAVA调用JNA修改桌面壁纸
- 修改Launcher3的workspace的应用图标的行列数:
- 修改Launcher3的Hotseat的位置到右侧的方法
- Launcher3桌面Icon的文字size的 修改
- android4.4 Launcher3 修改配置文件default_workspace.xml无效的解决方法
- android4.4 Launcher3 修改配置文件default_workspace.xml无效的解决方法
- 修改Launcher3中的workspace中的应用图标的大小
- android launcher3修改内置的系统图标显示
- 修改android N的Launcher3桌面应用图标
- launcher3 修改默认桌面布局
- 腾讯2017暑假实习生编程题有趣的数字
- Eclipse调用Spark on yarn问题及解决
- NodeJS基础
- 配置 Spring.NET
- 解决Android中TextView首行缩进的问题
- Launcher3桌面壁纸被拉伸模糊的修改
- C++ Primer 第5章 知识点回顾
- Edit Control控件接收换行符
- NYOJ-42-一笔画问题(欧拉路 判图联通)
- spring jdbc:initialize-database
- iOS中Bitcode的介绍及配置
- Linux系统启动过程分析
- win7中如何搭建个人网站
- 背景加载模糊到清晰