0xAliHn
0xAliHn

Reputation: 19280

How to show my application all activity layout in landscape mode using landscape flag only once

I have an application which contains multiples activity. I want to show all the activity layout in landscape mode for my applicaiton.

There is a common way to do that, which is declaring android:screenOrientation="landscape" flag for each activity in android manifest file.

But this is weird when I have lots of activity and declaring that flag for all activity tag where I want to show all activity in landscape mode by default.

Is it possible or any way to declare that flag only once either manifest or activity to show all of my application activity layout in landscape mode?

Upvotes: 0

Views: 240

Answers (2)

ND1010_
ND1010_

Reputation: 3841

There is not any a common way to do that, which is declaring android:screenOrientation="landscape" flag for each activity in android manifest file.

You have must apply android:screenOrientation="landscape/landscape" to each an every activity in your AndroidManifest.xml file

or

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
    or
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);

Upvotes: 0

Jd Prajapati
Jd Prajapati

Reputation: 1971

You can create BaseActivity and add layout type which you want

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
or
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);

Extend BaseActivity to all activities class.

Upvotes: 1

Related Questions