launcher3图标icon背景及文字处理
2015-01-17 11:59
549 查看
图标聚焦背景
packages\apps\Launcher3\res\drawable\focusable_view_bg.xml
图标文字背景
packages\apps\Launcher3\src\com\android\launcher3\BubbleTextView.java
packages\apps\Launcher3\src\com\android\launcher3\Utilities.java
static final int[] APP_ICON_BG = {
R.drawable.appsiconbg,
R.drawable.appsiconbg,
R.drawable.appsiconbg,
R.drawable.appsiconbg,
R.drawable.appsiconbg
};
static Bitmap createIconBitmap(Drawable icon, Context context) {
synchronized (sCanvas) {
...
if (debug) {
// 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)
{
int index = new Random(System.currentTimeMillis()).nextInt(5);
//Bitmap backBitmap = BitmapFactory.decodeResource(context.getResources(),APP_ICON_BG[index]);
Bitmap backBitmap = BitmapFactory.decodeResource(context.getResources(),R.drawable.appsiconbg);
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);
}
}
...
// 如果原图标太大,看不到背景,可以把原图标缩小
//icon.setBounds(left, top, left+width, top+height);
icon.setBounds(left+15, top+15, left+width-15, top+height-15);
}
参考http://blog.csdn.net/xuhui_7810/article/details/36901815
packages\apps\Launcher3\res\drawable\focusable_view_bg.xml
图标文字背景
packages\apps\Launcher3\src\com\android\launcher3\BubbleTextView.java
packages\apps\Launcher3\src\com\android\launcher3\Utilities.java
static final int[] APP_ICON_BG = {
R.drawable.appsiconbg,
R.drawable.appsiconbg,
R.drawable.appsiconbg,
R.drawable.appsiconbg,
R.drawable.appsiconbg
};
static Bitmap createIconBitmap(Drawable icon, Context context) {
synchronized (sCanvas) {
...
if (debug) {
// 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)
{
int index = new Random(System.currentTimeMillis()).nextInt(5);
//Bitmap backBitmap = BitmapFactory.decodeResource(context.getResources(),APP_ICON_BG[index]);
Bitmap backBitmap = BitmapFactory.decodeResource(context.getResources(),R.drawable.appsiconbg);
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);
}
}
...
// 如果原图标太大,看不到背景,可以把原图标缩小
//icon.setBounds(left, top, left+width, top+height);
icon.setBounds(left+15, top+15, left+width-15, top+height-15);
}
参考http://blog.csdn.net/xuhui_7810/article/details/36901815
相关文章推荐
- CListCtrl ICon图标模式下,如何让设置背景透明与文字置透明
- ListBox填充背景,图标,文字
- 怎样去掉桌面图标阴影(文字背景透明)
- ActionBar的简单使用(修改背景颜色,文字居中,图标)
- icon图标和文字整体居中在button按钮
- iOS - 设置Iconfont文字“图标”
- 桌面图标的文字背景色如何恢复为透明
- UITabBar背景、icon图标颜色、被选中背景设置以及隐藏UITabBar的方式
- css3处理sprite背景图压缩来解决H5网页在手机浏览器下图标模糊的问题
- launcher3的hotseat的图标文字处理
- 为网站文字前面添加图标 在线调用 Font Awesome 字体icon小图标 美化网站
- 如何在工具栏中,加上图标和文字?(How To Add Icon And Text)
- 如何处理小图标与文字混排的多种解决方案
- WinXP\2003怎么让桌面图标的文字背景透明(终于去掉了讨厌的图标蓝色背景文字)
- uitextfield 设置左图标以及图标文字间距,输入框背景图切换
- 下拉框右侧图标替换+背景透明(文字不透明)
- windows xp桌面图标文字背景不是透明的改透明
- (个人原创)zabbix 图标下方文字显示为方块的处理办法
- 【※桌面图标背景壁纸色问题怎么处理※】
- 【iOS开发-31】UITabBar背景、icon图标颜色、被选中背景设置以及隐藏UITabBar的两种方式