Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set android show vertical orientation?

From following .xml file I set xml to show TabHost but after i run it on emulator it show both both orientation. i want to set it to show only one orientation. How do i do? THanks you.

<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/tabhost"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical">

    <RelativeLayout 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent"
        android:orientation="vertical">

        <FrameLayout android:id="@android:id/tabcontent"
             android:layout_width="fill_parent" 
             android:layout_height="fill_parent"
             android:layout_alignParentTop="true" 
             android:layout_above="@android:id/tabs" />
    <TabWidget android:id="@android:id/tabs"
             android:layout_width="fill_parent" 
             android:layout_height="wrap_content"
             android:layout_alignParentBottom="true" />
    </RelativeLayout>
</TabHost>
like image 693
April Smith Avatar asked May 25 '11 04:05

April Smith


People also ask

How do I fix the orientation on my android?

To adjust the screen rotation settings: Swipe down from the top of the screen to open the Quick settings panel. Look for the screen orientation icon. Depending on your settings, you may need to look for the Portrait, Landscape, or Auto Rotate icon.

How do I turn off landscape mode on android?

If you want to disable Landscape mode for your Android app (or a single activity) all you need to do is add: android:screenOrientation="portrait" to the activity tag in AndroidManifest.

What is the default orientation in android?

On android phones, the orientation typically defaults to portrait. When you disable auto-rotation, the screen will always remain in a portrait mode. On android tablets, the orientation typically defaults to landscape. When you disable auto-rotation, the screen will always remain in a landscape mode.


1 Answers

add this line in your manifest.xml file.

<activity android:name=".activity"
  android:screenOrientation="portrait">
</activity>

if you want only landscape orientation then change to landscape instead of portrait

like image 70
Niranj Patel Avatar answered Sep 19 '22 05:09

Niranj Patel