Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set the orientation to portrait from code

I know I can limit the orientation from the manifest file. Like this

android:screenOrientation="portrait"

But is it possible to set the orientation from code ?

for example setting the activity to full screen can be done both from manifest and from code this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

like image 321
Lukap Avatar asked Mar 07 '26 12:03

Lukap


1 Answers

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
like image 77
Andreas Eriksson Avatar answered Mar 10 '26 01:03

Andreas Eriksson



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!