一、桌面图标的大小调整
方法一(推荐):修改Launcher下的xml配置文件,调整图标的大小——位置放大
这种调整是对所有的桌面icon进行等比例放大和缩小的,根据分辨率在一定程度上保证了图标不会出现变形、失真的效果。
alps\packages\apps\Launcher3\res\xml\device_profiles.xml
<grid-option
launcher:name="3_by_3"
launcher:numRows="3"
launcher:numColumns="3"
launcher:numFolderRows="3"
launcher:numFolderColumns="3"
launcher:numHotseatIcons="3"
launcher:dbFile="launcher_3_by_3.db"
launcher:defaultLayoutId="@xml/default_workspace_3x3" >
<display-option
launcher:name="Go Device"
launcher:minWidthDps="296"
launcher:minHeightDps="491.33"
launcher:iconImageSize="74"
launcher:iconTextSize="12.0"
launcher:canBeDefault="true" />
grid-option>
其中的launcher:iconImageSize="74"为icon的大小调整,auncher:iconTextSize="12.0"为icon下方对应字体的大小调整。
注意:这个字体的大小调整不受设置下的字体大小调整的影响。
方法二(根据情况采用):在Launcher代码应用中修改——图形放大
alps\packages\apps\Launcher3\src\com\android\launcher3\BubbleTextView.java
alps\packages\apps\Launcher3\src\com\android\launcher3\FastBitmapDrawable.java
在BubbleTextView.java中:
private void applyIconAndLabel(ItemInfoWithIcon info) {
FastBitmapDrawable iconDrawable;
......
iconDrawable = newIcon(getContext(), info);
mDotParams.color = IconPalette.getMutedColor(info.bitmap.color, 0.54f);
setIcon(iconDrawable);
setText(info.title);
if (info.contentDescription != null) {
setContentDescription(info.isDisabled()
? getContext().getString(R.string.disabled_app_label, info.contentDescription)
: info.contentDescription);
}
}
在这个方法中,通过传过来的info参数,newIcon(getContext(), info)方法来获取iconDrawable 并完成setIcon(iconDrawable);通过查看发现来自FastBitmapDrawable.java中的newIcon(Context context, ItemInfoWithIcon info)方法:
/**
* Returns a FastBitmapDrawable with the icon.
*/
public static FastBitmapDrawable newIcon(Context context, ItemInfoWithIcon info) {
FastBitmapDrawable drawable = newIcon(context, info.bitmap);
drawable.setIsDisabled(info.isDisabled());
return drawable;
}
/**
* Creates a drawable for the provided BitmapInfo
*/
public static FastBitmapDrawable newIcon(Context context, BitmapInfo info) {
final FastBitmapDrawable drawable;
if (info instanceof Factory) {
drawable = ((Factory) info).newDrawable();
} else if (info.isLowRes()) {
drawable = new PlaceHolderIconDrawable(info, context);
} else {
drawable = new FastBitmapDrawable(info);
}
drawable.mDisabledAlpha = Themes.getFloat(context, R.attr.disabledIconAlpha, 1f);
return drawable;
}
}
在这里我们看看到Themes.getFloat(context, R.attr.disabledIconAlpha, 1f);其中的第三个参数"1f"可以进行适当的调整(只能做小幅度的调整,根据手机分辨率来)如:1.1f为放大图标,0.9f为缩小,1f为原样显示。
二、桌面图标圆角调整
图标的形状是由frameworks\base\packages\overlays\IconShapeXxxxOverlay来决定的,这里提供下当为方形时的圆角调整,在alps/frameworks/base/core/res/res/values/config.xml中:
<string name="config_icon_mask" translatable="false">"M50,0L79,0C89.4,0 100,10.6 100,21L100,79C100,89.4 89.4,100 79,100L21,100C10.6,100 0,89.4 0,79L0,21C0,10.6 10.6,0 21,0L50,0Z"string>
在这里我将原来的圆角调整成新的圆角21。
通过查询网络知识了解到:
“M50,0L92,0C96.42,0 100,4.58 100 8L100,92C100, 96.42 96.42 100 92 100L8 100C4.58, 100 0 96.42 0 92L0 8 C 0 4.42 4.42 0 8 0L50 0Z”:这是一个 SVG 路径数据的字符串。 SVG (Scalable Vector Graphics) 是一种基于 XML 的矢量图像格式。
M50,0: M 命令 (Move To) 将画笔移动到坐标 (50, 0)。
L92,0: L 命令 (Line To) 从当前位置画一条直线到坐标 (92, 0)。
C96.42,0 100,4.58 100 8: C 命令 (Cubic Bézier Curve) 从当前位置画一条三次贝塞尔曲线到坐标 (100, 8)。这个命令需要三个控制点,这里是 (96.42, 0)、(100, 4.58) 和 (100, 8)。 这会绘制一个圆角。
L100,92: 画一条直线到 (100, 92)。
C100, 96.42 96.42 100 92 100: 画一条三次贝塞尔曲线到 (92, 100),用以生成圆角。
L8 100: 画一条直线到 (8, 100)。
C4.58, 100 0 96.42 0 92: 画一条三次贝塞尔曲线到 (0, 92),用以生成圆角。
L0 8: 画一条直线到 (0, 8)。
C 0 4.42 4.42 0 8 0: 画一条三次贝塞尔曲线到 (8, 0),用以生成圆角。
L50 0: 画一条直线到 (50, 0)。
Z: Z 命令 (Close Path) 将当前点连接到路径的起始点 (50, 0),闭合路径。