Skip to content Skip to sidebar Skip to footer

Android Shortcut Bitmap Launcher Icon Size

I have problems to find out the correct launcher icon size for my shortcut. On my Nexus 7.2 the value of android.R.dimen.app_icon_size (see code) is 96 pixels. But if I measure the

Solution 1:

I have found out a working solution:

@TargetApi(Build.VERSION_CODES.HONEYCOMB)privateintlauncherLargeIconSize() {
    ActivityManageractivityManager= (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
    return activityManager.getLauncherLargeIconSize();
}

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

Solution 2:

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

Solution 3:

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

Post a Comment for "Android Shortcut Bitmap Launcher Icon Size"