1

I have a relativelayout with a scrollview like this:

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

I want to stop the orientation changes and make it fixed vertical. How can I do this?

Ra Ghazi
  • 129
  • 3
  • 10

3 Answers3

3

Add this to the MainActivity in AndroidManifest.xml:

<activity
...
android:screenOrientation="landscape"
... >
</activity>
Trikaldarshiii
  • 11,174
  • 16
  • 67
  • 95
Al0x
  • 917
  • 2
  • 13
  • 30
0

under your

 <activity>

tag in your manifest you can put

android:screenOrientation="portrait"
android:configChanges="keyboard|keyboardHidden|orientation" >
JRowan
  • 6,824
  • 8
  • 40
  • 59
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

Trikaldarshiii
  • 11,174
  • 16
  • 67
  • 95