Search code examples
androidandroid-layoutandroid-studioscreen-size

AndroidStudio: Why are alternative screen-size layouts being ignored?


I am testing the ability to use different layouts directories for different screen sizes (android training). I am using genymotion for my emulators (because I have a windows10 with AMD processor).

My directory structure looks like:

MyProject/
  res/
    layout/
        activity_main.xml
    layout-large/
        activity_main.xml
    layout-sw1440dp/
        activity_main.xml
    layout-xlarge/
        activity_main.xml

In every version of activity_main.xml I have one TextView.

In the normal version I have android:layout_alignParentTop = "true".

In the other three versions I have android:layout_alignParentBottom = "true".

So when I test using genymotion's Nexus 6 with resolution: 1440x2560, I would expect to see the TextView at the bottom. But it is always at the top.

However, when I am editing one of the large xml's, the Android Studio Preview Pane does show the TextView at the bottom.


Solution

  • You are confusing DP and pixels, they are not the same. The Nexus 6 is indeed 1440x2560, but that translates to 410x730 in DPs.

    See this table for reference.