If you want your app to have either of one fixed position: Landscape or Portrait, you can do it by setting the orientation in AndroidManifest.xml using android:screenOrientation attribute.
Example :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.code2care.tools.example"
android:installLocation="auto"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="21" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.FLASHLIGHT" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<uses-feature android:name="android.hardware.camera.flash" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:installLocation="auto"
android:label="@string/app_name"
android:theme="@style/Theme.AppCompat.Light.NoActionBar" >
<activity
android:screenOrientation="portrait"
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".App"
android:label="@string/app_name" >
</activity>
</application>
</manifest>
Note: If you have two or more activities then you need to set the orientation for each of them separately.
Example :
<!--Activity 1 --!>
<activity
android:screenOrientation="portrait"
android:name=".Screen1"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!--Activity 2 --!>
<activity
android:screenOrientation="landscape"
android:name=".Screen2"
android:label="@string/app_name" >
</activity>
More Posts related to android,
- appcompat_v7 errors after updates to API level 21 Material Theme
- adb: The Android Debug Bridge and Commands
- The Android Virtual Device myEmulator is currently running an emulator and cannot be deleted.
- How to make TextView Text Transparent [Android]
- Android is starting optimizing... app 1 of 1
- How to make Text in TextView bold and italic in Android
- Android Development - How to switch between two Activities
- Android : IOException: Unable to open sync connection!
- Android Toolbar example with appcompat_v7 21
- How to Change Android Title Bar Color?
- How to Add Padding to Android TextView
- JavaScript : redirect page to other url
- Programmatically Send an Email from Android App using Intent
- What is Android Toast.LENGTH_SHORT and Toast. LENGTH_LONG durations
- [Soluiton] You already have the latest version of Android Studio installed
- Detect swipes on Android Activity
- Add Buttons at the bottom of Android Layout xml file
- Android Lint app_name is not translated in af (Afrikaans) am (Amharic) ar (Arabic) bg (Bulgarian)
- Hide Navigation Bar from Android Screen Activity
- Android Disable EditText from Auto Focus on Activity load
- Toast not getting displayed Android App
- How to Enable Developers Option in Android Phones Settings
- Android : Duplicate registration for activity com.example.abc
- Android ListView turns Black or Flickers while Scrolling
- Android Studio Ctrl Shift o auto import not working
More Posts:
- Error code - 7: There's a more permanent way to sign in to Microsoft Teams - Teams
- How to fix: You will need Google Chrome to install most apps, extensions and themes. - Chrome
- You're not on Teams yet, but you can set it up for your organization. [Microsoft Teams Login Error] - Microsoft
- Deep Dive: Why avoid java.util.Date and Calendar Classes - Java
- How to stop MongoDB Server running on Ubuntu - Ubuntu
- How to Create Absolute References in Microsoft Excel for Mac - Microsoft
- How to Add Padding to Android TextView - Android
- Switch between Python 2.x 3.x versions in Mac Terminal - MacOS