-1

I just want to know that , is it a good practice to use single large icon and re-size them programatically for all different resolution rather having 4 to 5 icons in different folder like (hdpi , mdpi , ldpi , xhdpi , xxhdpi).

So , can we use DisplayMetrics class or to have different layout folder for all resolution to change the icon width-height programatically.

Please suggest me some solution.

Anshuman Pattnaik
  • 883
  • 3
  • 16
  • 37

2 Answers2

0

It is not a good idea to do this programatically when the functionality exists to display the correct icon automatically. The folders... hdpi , mdpi , ldpi , xhdpi , xxhdpi

If you look at the example provided in Eclipse, it shows the proper dimensions for your icon. You should match your icon to each of those sizes. Start with the largest. Then use Photoshop to resize the images accordingly for the smaller sizes.

The upshot is that the system will automatically choose the correct image for whatever screen is being used, and it will always look perfect. And no system resources are wasted on resizing the image.

durbnpoisn
  • 4,666
  • 2
  • 16
  • 30
  • Thanks but if we have so many icons then , it will be bit longer to design for each screen sizes in photoshop – Anshuman Pattnaik Mar 01 '16 at 17:52
  • It's 5 images. And all you have to do is resize them. It's not like that takes years to do. If you're that concerned about it, then just use the largest. Because the system will scale it. This, btw, is assuming you are talking about the launcher icon. That's what I'm talking about. If you have individual icons for your activities, then yeah, that's a lot of work. But it is the correct way to do it. – durbnpoisn Mar 01 '16 at 17:55
0

It's not good to use single large icon / image and manipulate it from code but if you are looking to reduce you app size then you can go with the Vector Drawables. Otherwise you have to work with standard way, i.e. by creating different icons / images as per the screen resolution.

iSandeep
  • 597
  • 8
  • 24
  • The big advantage of using vector graphics is that they are rendered at run time, so will automatically be rendered at the pixel density of the device on which they are being rendered – thereby giving smooth graphics irrespective of device capabilities. They are also usually much smaller than the bitmap version of the same graphic. They do, however, come with a computational overhead at run time which may be an issue for more complex graphical elements. – iSandeep Mar 01 '16 at 18:08