增加app在内外显示,支持长按显示隐藏,优化命名,主页app显示还有问题
This commit is contained in:
@@ -129,19 +129,31 @@ public class IconCacheManager {
|
||||
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
if (icon instanceof AdaptiveIconDrawable) {
|
||||
// 分别获取背景和前景Drawable
|
||||
Drawable[] layers = new Drawable[2];
|
||||
layers[0] = ((AdaptiveIconDrawable) icon).getBackground();
|
||||
layers[1] = ((AdaptiveIconDrawable) icon).getForeground();
|
||||
LayerDrawable layerDrawable = new LayerDrawable(layers);
|
||||
// Drawable[] layers = new Drawable[2];
|
||||
// layers[0] = ((AdaptiveIconDrawable) icon).getBackground();
|
||||
// layers[1] = ((AdaptiveIconDrawable) icon).getForeground();
|
||||
// LayerDrawable layerDrawable = new LayerDrawable(layers);
|
||||
//
|
||||
// int width = icon.getIntrinsicWidth();
|
||||
// int height = icon.getIntrinsicHeight();
|
||||
//
|
||||
// Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
|
||||
// Canvas canvas = new Canvas(bitmap);
|
||||
//
|
||||
// layerDrawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
|
||||
// layerDrawable.draw(canvas);
|
||||
|
||||
int width = icon.getIntrinsicWidth();
|
||||
int height = icon.getIntrinsicHeight();
|
||||
|
||||
Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
|
||||
// 创建一个大小与原始Drawable相同的位图
|
||||
Bitmap bitmap = Bitmap.createBitmap(
|
||||
icon.getIntrinsicWidth(),
|
||||
icon.getIntrinsicHeight(),
|
||||
Bitmap.Config.ARGB_8888
|
||||
);
|
||||
Canvas canvas = new Canvas(bitmap);
|
||||
// 关键步骤:设置Drawable的绘制边界
|
||||
icon.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
|
||||
icon.draw(canvas);
|
||||
|
||||
layerDrawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
|
||||
layerDrawable.draw(canvas);
|
||||
bitmap.compress(Bitmap.CompressFormat.PNG, 100, editor.newOutputStream(0));
|
||||
editor.commit();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user