预置壁纸的分辨率和屏幕的分辨率一样,设置预置的壁纸出现壁纸拉伸变形的问题

在mtk平台上,我预置壁纸的分辨率和屏幕的分辨率一样,当设置壁纸为预置的壁纸时会出现壁纸拉伸变形的问题

具体修改如下:

--- a/packages/apps/Launcher3/WallpaperPicker/src/com/android/launcher3/WallpaperCropActivity.java
+++ b/packages/apps/Launcher3/WallpaperPicker/src/com/android/launcher3/WallpaperCropActivity.java
@@ -319,11 +319,13 @@ public class WallpaperCropActivity extends Activity {
             int maxDim = Math.max(maxDims.x, maxDims.y);
             int minDim = Math.max(minDims.x, minDims.y);
 
+            int realWith = minDim;
             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);
+                realWith = realSize.x;
 				
 				Log.i(LOGTAG, "getDefaultWallpaperSize, realSize: " + realSize);
             }
@@ -333,14 +335,16 @@ public class WallpaperCropActivity extends Activity {
             // for the intended parallax effects
             final int defaultWidth, defaultHeight;
             if (isScreenLarge(res)) {
-                defaultWidth = (int) (maxDim * wallpaperTravelToScreenWidthRatio(maxDim, minDim));
+                //defaultWidth = (int) (maxDim * wallpaperTravelToScreenWidthRatio(maxDim, minDim));
                 defaultHeight = maxDim;
+                defaultWidth = realWith;
 				
 				Log.i(LOGTAG, "getDefaultWallpaperSize, wallpaperTravelToScreenWidthRatio(maxDim, minDim): " + 
 					wallpaperTravelToScreenWidthRatio(maxDim, minDim));
             } else {
-                defaultWidth = Math.max((int) (minDim * WALLPAPER_SCREENS_SPAN), maxDim);
+                //defaultWidth = Math.max((int) (minDim * WALLPAPER_SCREENS_SPAN), maxDim);
                 defaultHeight = maxDim;
+                defaultWidth = realWith;
             }
             sDefaultWallpaperSize = new Point(defaultWidth, defaultHeight);
         }

 

你可能感兴趣的:(android)