如何设置android显示垂直方向?

Apr*_*ith 8 layout android orientation

从以下.xml文件中我设置xml以显示TabHost,但是在我在模拟器上运行它后,它同时显示两个方向.我想将其设置为仅显示一个方向.我该怎么办?谢谢.

<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>
Run Code Online (Sandbox Code Playgroud)

Nir*_*tel 24

在manifest.xml文件中添加此行.

<activity android:name=".activity"
  android:screenOrientation="portrait">
</activity>
Run Code Online (Sandbox Code Playgroud)

如果你只想横向,那么改为landscape而不是portrait

  • 如果它的片段???片段没有在清单中注册怎么办? (2认同)

Suj*_*jit 8

android:screenOrientation="portrait"在清单中的活动中设置此项.