Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically disabling screen rotations in the entire Android application

How do I programmatically disable screen rotations for an entire Android application?

like image 944
Krish Avatar asked Aug 08 '26 11:08

Krish


1 Answers

As in keep it in portrait or Landscape no matter which way device is tilted? You need to add this to your manifest inside the activity that you want to limit

 android:screenOrientation="portrait" //Or landscape for horizontal.

If you want it different between activities just make your manifest look like this.

        <activity android:name=".Activity1" 
        android:screenOrientation="landscape">       
        </activity>

        <activity android:name=".Activity2" 
        android:screenOrientation="portrait">
        </activity>

        <activity android:name=".Activity3" 
        android:screenOrientation="landscape">
        </activity>
like image 106
sealz Avatar answered Aug 11 '26 02:08

sealz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!