Lukap
Lukap

Reputation: 31963

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);

Upvotes: 2

Views: 4687

Answers (2)

Shailendra Singh Rajawat
Shailendra Singh Rajawat

Reputation: 8242

Activity. setRequestedOrientation(..)

Upvotes: 1

Andreas Eriksson
Andreas Eriksson

Reputation: 9027

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

Upvotes: 13

Related Questions