2011-05-25 89 views
7

從下面的.xml文件中我設置xml來顯示TabHost,但在模擬器上運行它後,它顯示兩個方向。我想將它設置爲僅顯示一個方向。我該怎麼做?謝謝。如何設置android顯示垂直方向?

<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> 

回答

25

將此行添加到您的manifest.xml文件中。

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

如果你想那麼只有橫向改爲landscape而不是portrait

+1

有沒有辦法在清單全球做到這一點? – shim 2012-12-11 06:20:59

+2

如果它的一個碎片碎片沒有在清單內註冊,該怎麼辦? – 2013-08-12 17:00:17

8

在您的清單活動中設置此android:screenOrientation="portrait"

相關問題