Android dp and available screen space -


i'm having trouble understanding how layout app universal compatibility.

for i'm doing test android studio preview on :

  • nexus 1 : 480 x 800, hdpi
  • nexus 4 : 768 x 1280, xhdpi

the nexus 4 has button bar @ bottom, there's 1200 available pixels. meaning vertical space on nexus 4 1.5 times of nexus one.

what confusing me automatic scaling. added several imagebutton drawables , tried setting layout_height both wrap_content , fixed amount in dp. on nexus 4 screen, if mesure in px, button ends being 74px high. if switch nexus 1 preview, it's 55px high. seem normal behavior according dp/px converter.

but 74 1.34 times bigger 55, not 1.5. how come?

this mean if fill screen button on nexus 4, , switch nexus one, there's not enough space fit buttons, since don't reduced enough. :

nexus example

you can see bottom button on nexus 1 overlapping on previous 1 because of lack of space.

is intended behavior (dp scaling less screen size difference)? if so, what's way prevent problem above? if not, doing wrong?

strangely, isn't case when going xhdpi xxhdpi. if compare nexus 4 , nexus 5 (1080 x 1920, xxhdpi), screen 1.5 times bigger, scaling make drawable 1.5 times bigger (74px -> 111px) there no problem.

thanks

edit : guess "weird" thing example i'm trying make "single page" have scrollable. achieve this, maybe should use weights instead?

edit2 : behavior different if use multiple pictures (drawable-size folders) rather one?


Comments