I am working on an app which is able to add shortcuts icons to the homescreen.
What is the correct icon size for Android tablets? (Or better said, how to get it at runtime?) It seems to differ from what is written on this page.
I have switch on DisplayMetrics.densityDpi and change the icon size accordingly. But it does not work for all devices..Gnex seems to be ok, but my Galaxy Tab while beeing DisplayMetrics.DENSITY_MEDIUM
device displays only 48x48px icon (as it is in guidelines), but usual launcher icons are 72x72 pixels and not 48x48 - it differs from guidelines? Is it possible that it is related to TouchWiz UI and thus it differs from pure Android? Or where is the problem? Also good to note, that apps itself displays correct launcher icon (it takes the icon from hdpi folder), but at runtime it looks like it is mdpi device:/
Thanks
Asked
Active
Viewed 3,079 times
2

simekadam
- 7,334
- 11
- 56
- 79
-
are you used display metric for display size?.... – QuokMoon Dec 29 '12 at 18:05
-
I have a switch on DisplayMetric.densityDpi.. And accordingly I change the icon size – simekadam Dec 29 '12 at 18:07
-
have altered the question little bit, it should be more comprehensible now..thanks – simekadam Dec 29 '12 at 18:19
2 Answers
6
Android tablets looks one bucket up, when looking for launcher icon..That means mdpi
device will actually look into hdpi
folder..
This code returns correct size for launcher icons
ActivityManager am = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
int iconSize = am.getLauncherLargeIconSize();
Answer is based on this g+ post by Nick Butcher

simekadam
- 7,334
- 11
- 56
- 79
-
nice. so it's used for honeycomb and above , and for lower APIs you use something else ? – android developer Dec 30 '12 at 21:21
-
actually whole my app does not support lower than version 14 API..:) so thats what I use.. Anyway, how many tablets do have older than honeycomb android versions..Maybe Kindles Fire?(I am not sure about that)..I have never had any tablet with lower than honeycomb OS version in my hands.. And when I think about it, I think that just because before honeycomb there wasn't any tablet support at all in Android, it coudle be the same as on phones..(no one bucket up rule) – simekadam Dec 30 '12 at 21:29
-
For API<11 you can use int size1 = (int) getResources().getDimension(android.R.dimen.app_icon_size); see http://stackoverflow.com/questions/18635135/android-shortcut-bitmap-launcher-icon-size/18980226?iemail=1&noredirect=1#18980226 – almisoft Sep 24 '13 at 21:10
1
best thing you use the android assets studio tool for this task .
it will automatically create the correct sizes and put them in the correct folders .

android developer
- 114,585
- 152
- 739
- 1,270
-
ok..maybe badly written question:) My app adds programmatically shortcuts to homescreen.. – simekadam Dec 29 '12 at 20:27
-
well if it creates shortcuts to your app itself , it should work anyway... use intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(context,R.drawable.ic_launcher)); – android developer Dec 29 '12 at 20:55
-
..the icon gets downloaded from web. Basicaly I have a bitmap which I have to scale (up/down). According to the docs, those icons should be exactly as my app creates them..Maybe I am overlooking something, or the TouchWiz UI is so weird..(it definitely is:D) I will try run emulator with tablet resolution and I will see icons there.. – simekadam Dec 29 '12 at 21:11
-
so use this : http://developer.android.com/reference/android/content/Intent.html#EXTRA_SHORTCUT_ICON , and use the correct size of the icon (as used by the tool i've written about ) . – android developer Dec 29 '12 at 21:43
-
thats exactly what I am doing:) I have tried now getting the size not via display metrics, but from the actuall R.drawable.ic_launcher Resource. Still getting 48 instead of 72.. (I do not create shortcut to the app itself at runtime, but the app basically creates various shortcuts to other apps,..) – simekadam Dec 29 '12 at 22:26
-
you mean that on galaxy tab it doesn't work well ? what do you expect it to be? the original first galaxy tab has mdpi , so the launcher icon should have the size of 48x48 pixels . specs of galaxy tab : http://www.gsmarena.com/samsung_p1000_galaxy_tab-3370.php – android developer Dec 29 '12 at 22:39
-
It seems to not work on any tablet..I have this one: http://www.gsmarena.com/samsung_galaxy_tab_10_1_p7510-3894.php It is also mdpi, but icons are 72x72 pixels..I have tested it in emulator (tablet resolution and screen size) and it just looks like tablets have this icon sizing different.. – simekadam Dec 29 '12 at 22:49
-
have you tried providing the xhdpi icon size (or even the xxhdpi) ? maybe it will auto-resize accordingly ? – android developer Dec 29 '12 at 23:37
-
yes, I have those icon sizes (launcher icons I created with android assets editor). I even trie to recompute 48dp to px with this code, still getting the same..`(int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 48, r.getDisplayMetrics());` Thats really weird..In docs (even updated for tablets) they still write, that icon resources has to be 48dp. The tablet is mdpi, that means scaling factor is 1. I icons are 72px though, so it should be 1.5.. – simekadam Dec 30 '12 at 07:07
-
from where do you get 72 pixels , and is it even noticeable for you as an end user? – android developer Dec 30 '12 at 08:45
-
I have taken several screenshots after I spotted the icon sizing is different. It is nothing what ruins the experience, the icon is still pretty good to hit with the finger, the only problem is, it just looks weird. Here is screenshot where you can see Maps icon in 72px and icon created by my app which is only 48px: http://cl.ly/image/0l3R23323R05 – simekadam Dec 30 '12 at 09:00
-
is it possible it has something to do with the launcher which shows it larger ? or maybe samsung made some tweaking to make it look like this ? – android developer Dec 30 '12 at 09:51
-
I thought so, so I did same testing with stock 4.2 in emulator and it seems to be the same..Tablets just do have those sizes different..Check this screenshot..Smaller icons are from my app, bigger are default..(The one The Verge icon which is 72px is after I tried once to force those size there in my code..The smaller are all based on standard 48dp constraint).. http://cl.ly/image/0u09390e3a0B – simekadam Dec 30 '12 at 13:26
-
how come i see different icons sizes on the image you've written here ? also , which one is the one that you've created using your app ? – android developer Dec 30 '12 at 14:37
-
all smaller are from my app..All bigger except the one which is titled "The Verge" are default from Android. (The Verge icon is also from my app - I forced the resolution to 72x72px) – simekadam Dec 30 '12 at 14:41
-
what if , you get the size of the icon of your own app , and by using the size of it , use it for the icon to be sent to the launcher ? – android developer Dec 30 '12 at 15:14
-
Actually I tried to do it also this way (in desperation:)..Maybe I was doing it wrong, just look what I am getting.. (lines 238,239...there is lots of other code trying to solve it) http://cl.ly/image/2e45170p3G1v The app was running on the samsung tablet.. – simekadam Dec 30 '12 at 15:35
-
-