How to fix layout orientation to vertical? How to fix layout orientation to vertical? android android

How to fix layout orientation to vertical?


In your AndroidMainfest.xml file find the tags of the activities you wish to lock to a given rotation, and add this attribute:

android:screenOrientation="portrait"


Use setRequestedOrientation() as shown:

public void onCreate(Bundle savedInstanceState) {    super.onCreate(savedInstanceState);setContentView(R.layout.main);setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);


in your activity parameters in Manifest File

<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android"    package="com.statepermit" android:versionCode="1" android:versionName="1.0">    <application android:icon="@drawable/stateheader" android:label="@string/app_name">        <activity android:name=".statepermit" android:label="@string/app_name"            android:theme="@android:style/Theme.NoTitleBar" android:screenOrientation="portrait">            <intent-filter>                <action android:name="android.intent.action.MAIN" />                <category android:name="android.intent.category.LAUNCHER" />            </intent-filter>        </activity>    </application>    <uses-sdk android:minSdkVersion="7" /></manifest>

android:screenOrientation="portrait"