0

So, I am aware that you can define different layouts for different screens and orientations. The problem I have is in grasping which will be used when.
I am considering three devices (as an example):

  • Google Nexus 7
  • Samsung Galaxy S3
  • Some really small phone.
  • At the start, there is a main.xml in res/layout which is the default layout to be used in portrait mode. Then, you can define main.xml in res/layout-land which is the default layout to be used when the phone is held in landscape mode.
    These are the two layouts which will be used for Samsung Galaxy S3 and Nexus 7 and small phones because I have not defined anything specific.

    Now, I want to define a layout, specifically for the small phone and portrait mode, in addition to the ones mentioned above. It will go under res\layout-small\main.xml

    My question is: How will the layout for the small screen be chosen when it is held in landscape mode?

    An SO User
    • 24,612
    • 35
    • 133
    • 221
    • 1
      Everything you need - http://developer.android.com/guide/practices/screens_support.html – Simon Jul 27 '13 at 03:06
    • possible duplicate of [Application Skeleton to support multiple screen](http://stackoverflow.com/questions/12242111/application-skeleton-to-support-multiple-screen) – Simon Jul 27 '13 at 03:07

    1 Answers1

    0

    Links by @Simon are very useful. In addition to that the sample application NewsReader.zip on android's Supporting Different Screen Sizes page will help. If you read Use Orientation Qualifiers section it tell you what you want to do.

    You can define all the layouts in an XML file in the res/layout/ directory. To then assign each layout to the various screen configurations, the app uses layout aliases to match them to each configuration. Eg. for small screen portrait a file:

    res/values-sw600dp-port/layouts.xml:

    Its contents can be like:

    <resources>
        <item name="main_layout" type="layout">@layout/small_screen_portrait</item>
        <bool name="has_two_panes">false</bool>
    </resources>
    

    You can see the sample app for more. Hope this helps.

    Shobhit Puri
    • 25,769
    • 11
    • 95
    • 124