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
  • 10,994
  • 16
  • 64
  • 93
Al0x
  • 919
  • 2
  • 12
  • 27
0

under your

 <activity>

tag in your manifest you can put

android:screenOrientation="portrait"
android:configChanges="keyboard|keyboardHidden|orientation" >
JRowan
  • 6,640
  • 7
  • 37
  • 58
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
  • 10,994
  • 16
  • 64
  • 93