Should we EVER use dp values for width/height?
Posted
by
sandalone
on Stack Overflow
See other posts from Stack Overflow
or by sandalone
Published on 2012-07-02T15:12:38Z
Indexed on
2012/07/02
15:15 UTC
Read the original article
Hit count: 183
android-layout
I've come across a project done by some other team which I have to fix. They used dp
values for images' width/height. When I tried to adopt the layout for some tablets and/or mobiles, I've faced a lot of troubles.
For example, the image of 40x40 dp
has top padding of 15dp
. When such image is loaded by some new mobile screen, the image is not where is was supposed to be - it's either shifted or distorted or of the wrong size.
Now I need to propose a redesign of the whole app and I need some advise from the more experienced community.
Should I abandon such layout policy (described abobe) and do like this:
- make the image with the size of 40x40 px
- position the image for the mdpi screen
- set its height/width to wrap_content
- do like this for other images
- after I finish layout for mdpi, resize each image for ldpi, hdpi and xhdpi screens
- in case of a special mobile/tablet, make a special set of images + xml files
Is there a way when you would advise to use the explicit size of some images?
Do you advise setting the size of images in xml layout or setting size via photoshop or similar graphics tools and then resize images for other screen sizes or screen densities?
© Stack Overflow or respective owner