Android shortcut bitmap launcher icon size

 ̄綄美尐妖づ 提交于 2019-12-02 00:31:29

I have found out a working solution:

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private int launcherLargeIconSize() {
    ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
    return activityManager.getLauncherLargeIconSize();
}

int size1 = (int) getResources().getDimension(android.R.dimen.app_icon_size);
int size2 = Build.VERSION.SDK_INT >= 11 ? launcherLargeIconSize() : 0;
int size = size2 > size1 ? size2 : size1;

If you notice in the android res folder - there should be several drawable folders

drawable hdpi , drawable mdpi, drawable ldpi and so on each folder has designated images for each device, because each device shows images according to screen density, some devices have low density, and some have high density

which is why on one device your icon size is 96 px, and on another it is 72

the older and smaller devices are even 48 and 36

in order to fix the problem, you just have to populate the appropriate drawable folders, with the right size icon file, and then you wont have a problem

for more info, read this : Supporting multi screens in android

jboi

Getting the right size of a launcher icon seems to be not as straight forward as one might expect. I know that at least tablets go one folder up in the drawables folder to show larger icons then expected by the screen density.

Here is this a bit more discussed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!