How to Keep Screen Always in Portrait Mode in Landscape Mode How to Disable Landscape Mode


Full tutorial is given below. Dear Viewer we are working hard to maintain this website. We doesn't want any think from you. Its just a humble request If you thinks that this posts helps you please share this post with your friends.




So, in this tutorial we learn how to keep screen always in portrait mode or keep always in landscape mode. In other words how to disable or enable landscape mode in android studio.



You have to do this in your manifest file


So add this code into your AndroidManifest.xml file to keep screen always in portrait mode

AndroidManifest.xml


<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.usmtip.demoappbyusmtip" >

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.DemoAppByUsmtip" >
        <activity android:name=".MainActivity"
            
            android:screenOrientation="portrait" >
            
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>











So add this code into your AndroidManifest.xml file to keep screen always in landscape mode

AndroidManifest.xml


<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.usmtip.demoappbyusmtip" >

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.DemoAppByUsmtip" >
        <activity android:name=".MainActivity"

            android:screenOrientation="landscape" >
            
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>







Note : you have to add this code in your all actives in AndroidManifest.xml file.


That's it now run your app.










Post a Comment

0 Comments