Search code examples
androidorientationscreen-orientationandroid-orientation

7 inch tablet orientation query


I have created an android app which works fine on phone (portrait) and on 10 inch tablet (Landscape). But problem is with 7 inch tablet.It opens in portrait mode but uses UI of tablet..so UI is looking totally distracted. I want to open app in 7 inch in landscape mode..how could it be possible through code...? Any suggestions would be appreciated,. Thanks in advance.

Manifest file declaration ---

 <activity
        android:name=".MainActivityTheme"
        android:label="@string/app_name"
        android:screenOrientation="nosensor" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

Solution

  • Create a folder in /res directory as layout-xlarge-land and another one as layout-large-land , keep the same file in both the folders and you are done.

    These are recommended folders where you should put your files , this is not the complete list but it can be appended with many ,

    layout-xlarge-land  landscape for 10 inch tablets and 10.1
    layout-xlarge-port portrait for 10 inch tablets and 10.1
    layout-large-land landscape for 7 inch tablets and 7.1
    layout-large-port portrait for 7 inch tablets and 7.1
    

    move your layout file between these folders to properly use it.