ANDROID: ImageView for different sizes -


i new android studio; please excuse if query trivial. problem understanding layouts.

my layout , corresponding values folder shown below. problem correct layout not being picked up. example, nexus 4 (4.7inch, 768x1280, xhdpi), in landscape mode, layout being picked 'layout' folder. per understanding (which might totally wrong :) ) should have been picked layout-sw720dp-xhdpi. suggestions please?

layout-problem

sw stands smallest width. if device has width of 320dp in portrait mode , 720dp in landscape mode end device's smallest width 320dp.

try use layout-w720dp-xhdpi instead of layout-sw720dp-xhdpi , see if works.

how calculate device dimensions in dp

  1. calculate ppi (pixel per inch) of device.
    enter image description here
    enter image description here
  2. calculate dimensions of device using dp
    enter image description here
    enter image description here
    where:
    • enter image description here = screen width in pixels
    • enter image description here = screen height in pixels
    • enter image description here = screen diagonal in pixels
    • enter image description here = pixels per inch
    • enter image description here = screen diagonal in inches


edit:
according wikipedia "the nexus 7 (2013) screen has 1920×1200 pixel resolution (960dp × 600dp)". smallest width 600dp why layout isn't being used.
proof
ppi = (√(19202 + 12002))/7.02 = 322.53
width in dp = (1920*160)/322.53 = 952.47 = roughly 960dp
height in dp = (1920*160)/322.53 = 595.29 = roughly 600dp


Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -