T.Vert
T.Vert

Reputation: 279

About dpi and layout-swx

I have an ImageView 50x50dp.

I want to make it look good for all screens so I create different pictures for ldpi, mdpi and so on.

For mdpi that image will be 50x50px, for ldpi (0.75) 37x37px and so on.

I put those pictures in appropriate folders drawable-ldpi, drawable-mdpi and so on.

But now I want to make different layouts for tablets like 7" and 10" and I use different folders like layout-swXX and ImageView is 100x100dp in those layouts. And I would need a picture of 100x100px for mdpi.

Should I make another set of pictures for another layout folder? If yes, where should I put them? Something like drawable-mdpi-swXX?

And please don't refer me to those "Supporting Multiple Screens" article, I read it several times, it doesn't provide information about my question.

Upvotes: 0

Views: 43

Answers (1)

Dalija Prasnikar
Dalija Prasnikar

Reputation: 28516

If you need different sized images for different layouts and same dpi bucket, then you need to create two different set of images and name them differently and put in appropriate dpi folder.

In practice that means that for 50x50dp layout you would create image50.png sets and for 100x100dp layouts you would have image100.png sets (image50 and image100 are arbitrary names you can name your images whatewer you like, just give them different names)

So your drawable folders structure would look like

drawable-ldpi
   - image50.png (37x37 pix)
   - image100.png (75x75 pix)

drawable-mdpi
   - image50.png (50x50 pix)
   - image100.png (100x100 pix)

drawable-hdpi
   - image50.png (75x75 pix)
   - image100.png (150x150 pix)
...

And for layouts - in small ones use image50 for drawables and in large ones image100

Upvotes: 1

Related Questions