Akhil
Akhil

Reputation: 303

Screen orientation of an android application

Is it possible to write code on android manifest file that will automatically change screen orientation according to the device screen size?.

Upvotes: 2

Views: 79

Answers (4)

Henry
Henry

Reputation: 43798

As far as I know this cannot be done in the manifest. However, you can write some code to achieve this. Have a look at the setRequestedOrientation method of Activity. Details in the documentation.

However, this will probably not generate the best user experience.

Upvotes: 2

Pratik Dasa
Pratik Dasa

Reputation: 7439

Write line given below in your defined Activity in Androidmanifest.xml,

 android:screenOrientation="unspecified"

Upvotes: 0

Pankaj Zanzane
Pankaj Zanzane

Reputation: 1242

AFAIK Tablets have default orientation set to Landscape. So this should automatically handled

Upvotes: 0

Bhavin Nattar
Bhavin Nattar

Reputation: 3215

May this help you:

Instead of fixing the orientation on the manifest, you could use setRequestedOrientation. On the onCreate method of each activity, check if you are on a tablet or smartphone and set the desired orientation.

Another option could be Creating Multiple APKs for Different Screen Sizes, depending on your needs.

Upvotes: 2

Related Questions