1

我有一个这样的滚动视图的相对布局:

<RelativeLayout
 android:layout_width="fill_parent"
 android:layout_height="576dp"
 android:background="@drawable/text_main" 
 >

我想停止方向更改并使其垂直固定。我怎样才能做到这一点?

4

3 回答 3

3

将此添加到AndroidManifest.xml的MainActivity中:

<activity
...
android:screenOrientation="landscape"
... >
</activity>
于 2013-09-08T21:12:06.907 回答
0

There are two ways of doing this

  1. Static

        <activity
            android:name="com.photon.filnobep.activities.ActivitySettings"
            android:icon="@drawable/icon_small"
            android:label="@string/title_activity_activity_settings"
            android:logo="@drawable/icon_small"
            android:screenOrientation="landscape"
            android:theme="@style/MyTheme" >
        </activity>
    
  2. Pro-grammatically(In your java class)

    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);


Note: using Static method you still can change Orientation from you java Class

于 2013-09-08T21:28:58.893 回答
0

根据你的

 <activity>

您可以在清单中添加标签

android:screenOrientation="portrait"
android:configChanges="keyboard|keyboardHidden|orientation" >
于 2013-09-08T21:12:28.350 回答