在我的Android桌面上创建快捷方式时,我遇到了一些问题.
首先,我有一个72x72图标,我从SD卡加载到Bitmap对象.
使用该位图对象,我将其设置为我的图标资源.
我遇到的问题是当我设置它时,快捷方式上的图像偏离中心并被切断.从屏幕指标我得到72x72的大小,不知道交易是什么.
码:
Bitmap theBitmap = BitmapFactory.decodeFile("/sdcard/icon.png");
intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, theBitmap)
Run Code Online (Sandbox Code Playgroud)
我已经尝试过调整它并使用画布,可绘制和另一个位图使其工作,但是当重新启动手机时它恢复到一个小尺寸.
使用与可绘制资源相同的图标使其看起来很完美,但它不是动态的:
Parcelable iconResource = Intent.ShortcutIconResource.fromContext(this, R.drawable.icon);
intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconResource);
Run Code Online (Sandbox Code Playgroud)
使用三星Epic 4g w/2.1
android ×1