(1)Dimens.xml (res\values)文件中添加<dimenname="app_icon_size">76dip</dimen>
(2)Utilities.java (src\com\android\launcher2)文件中privatestatic void initStatics(Context context)函数中做如下修改//sIconWidth= sIconHeight = (int) resources.getDimension(android.R.dimen.app_icon_size);sIconWidth = sIconHeight = (int)resources.getDimension(R.dimen.app_icon_size);
(3)Utilities.java (src\com\android\launcher2)文件中staticBitmap createIconBitmap(Drawable icon, Context context)函数中
if (sourceWidth > 0 && sourceHeight> 0) {
// There are intrinsic sizes.
if(width < sourceWidth || height < sourceHeight) {
//如果图片长宽大于设置的长宽,就按比例裁剪
//It's too big, scale it down.
final float ratio = (float) sourceWidth / sourceHeight;
if (sourceWidth > sourceHeight) {
height = (int) (width / ratio);
} else if (sourceHeight > sourceWidth) {
width = (int) (height * ratio);
}
} else if (sourceWidth < width &&sourceHeight < height) {
//如果图片长宽小于设置的长宽,就采用图片长宽,达不到放大效果。所以要注释掉
// It's small, use the size they gave us.
//width= sourceWidth;
//height= sourceHeight;
}
}