6

I'm developing an application for a Samgsung Galaxy Tab (1024x600px). In a Activity I use few icons of 128x128px and looks great.

But I run it in a Samgsung Galaxy S (480x800) and icons are too large.

I put same icons at 100x100px in drawable-mdpi, but now It resized both devices. I suppose this is because Tab and Galaxy S are in the same range of density.

How can I do automatically use different icons according to SCREEN SIZE? I see layout-large, layout-xlarge is according to screen size, but is for layouts, not icons.

Thanks a lot!

Josue
  • 725
  • 2
  • 10
  • 22

3 Answers3

7

Well Now there is exists Better tools then assert generator in android studio

For application Icon ( Toolbar , ActionBar , DrawableLeft etc ) Use : http://romannurik.github.io/AndroidAssetStudio/icons-actionbar.html

For launcher (Application Icon ) Use : https://romannurik.github.io/AndroidAssetStudio/icons-launcher.html

But Here are some tricks and way to get the better resolution for icons and launcher icons.

Step 1 :

First go to the https://materialdesignicons.com and choose your icon . Or if you have your icon in good resolution then skip this step . Click the desired icon and click on "Advanced Export" it will open up a window like this below Try to generate as large icon as possible

Then click the "Icon" to generate icon (.png) . Well the trick is try to generate as large icon as possible for high resolution devices and the tools will handle it all for small devices but if you use small icon , while generating the icon for high end devices you will loose the icon resolution .

Step 2 :

Then go the Tools page and Upload the Iconenter image description here

Click the "Custom" if you want to color your icon . No matter what color of icon you are uploading , by using Custom you can generate any color you want . Then choose a name and click "Download .ZIP" . This will download the .zip file with the icon for most of the common resolution . You can copy and paste the res folder in your application project folder and you will see the icon in the drawable section .

sh0umik
  • 1,549
  • 2
  • 17
  • 27
0

You can use the width of the screen

DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
int width = dm.widthPixels /4;
-1

You have the same with drawable : http://developer.android.com/guide/practices/screens_support.html

mthpvg
  • 3,789
  • 3
  • 26
  • 34
  • I've read this documentation, but I don't understand you. I don't have any drawable-large, drawable-xlarge..., I think icons are according to density and layouts to resolution. But both devices are in the same range of density... – Josue Aug 30 '11 at 10:45
  • You have small icons in drawable-mdpi for the tab and big icons in drawable-hdpi for the phone ? They are not in the same range of density 170dpi versus 233. – mthpvg Aug 30 '11 at 11:26
  • I have a 100x100px icon in drawable-hdpi and a 128x128px icon in drawable-mdpi. I run the application and on the Tab and Galaxy S it uses the small icon! – Josue Aug 30 '11 at 11:36
  • Look at smallestWidth tag ("sw") – Chaosit Aug 23 '13 at 04:51