原创文章,转载注明出处:http://blog.csdn.net/deng0zhaotai/article/details/49633177
这里的修改均以横屏,分辨率为800*480为例,因为屏不同方向和分辨率使用的资源是不一样的,长按图标会出现格子,看到的布局,下面先来看下修改前后的对比图
修改前是4x4:
修改后是3x5:
修改的文件有layout-land/launcher.xml、values-land/dimens.xml、values/dimens.xml、Utilities.java
launcher.xml图标排列的修改
修改前:
修改后:
values-land/dimens.xml修改前:
106dp
74dp
64dp
58dp
修改后:
100dp
100dp
100dp
100dp
values/dimens.xml修改图标大小 修改前:
48dp
修改后:
70dp
Utilities.java文件添加图标背景图,在函数static Bitmap createIconBitmap(Drawable icon, Context context)上有这样一段代码
// 测试用,加入sColors色彩背景边框
if (false) {
// draw a big box for the icon for debugging
canvas.drawColor(sColors[sColorIndex]);
if (++sColorIndex >= sColors.length)
sColorIndex = 0;
Paint debugPaint = new Paint();
debugPaint.setColor(0xffcccc00);
canvas.drawRect(left, top, left + width, top + height,
debugPaint);
}
修改后把if里的条件改为true:
// 测试用,加入sColors色彩背景边框
if (true) {
// draw a big box for the icon for debugging
canvas.drawColor(sColors[sColorIndex]);
if (++sColorIndex >= sColors.length)
sColorIndex = 0;
Paint debugPaint = new Paint();
debugPaint.setColor(0xffcccc00);
canvas.drawRect(left, top, left + width, top + height,
debugPaint);
}
如果要加入自己的背景图可以尝试以下代码代替以上代码
// 添加Launcher图标背景图片
if (false) {
Bitmap backBitmap = BitmapFactory.decodeResource(
context.getResources(), R.drawable.android_bg);
int backWidth = backBitmap.getWidth();
int backHeight = backBitmap.getHeight();
if (backWidth != sIconWidth || backHeight != sIconHeight) {
Matrix matrix = new Matrix();
matrix.postScale((float) sIconWidth / backWidth,
(float) sIconHeight / backHeight);
canvas.drawBitmap(Bitmap.createBitmap(backBitmap, 0, 0,
backWidth, backHeight, matrix, true), 0.0f, 0.0f,
null);
} else {
canvas.drawBitmap(backBitmap, 0.0f, 0.0f, null);
}
}
R.drawable.android_bg是你自己的背景图片
Hotseat.java的常量
private static final int sAllAppsButtonRank = 2; // In the middle of the dock
修改后:
Hotseat.java的常量
private static final int sAllAppsButtonRank = 1; // In the middle of the dock
修改了app_icon_size的值为70后,在Apps(应用程序)主菜单模块界面会出现显示不全现象
由于values-land/dimens.xml的区域大小为以下值
80dp
76dp
-1dp
-1dp
5dp
5dp
5dp
5dp
修改为:
100dp
100dp
-1dp
-1dp
10dp
10dp
10dp
10dp