Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android:screenOrientation tag in application does not work

The android:screenOrientation tag when placed in <application> does not work. But when I put android:screenOrientation in a <activity> tag it works.

If android:screenOrientation tag works in <application> then, there would no need to put android:screenOrientation handling for every activity.

I wonder, why there is such strange behavior in Android platform for screenOrientation tag?

like image 340
Zoombie Avatar asked Feb 21 '11 05:02

Zoombie


People also ask

How to handle screen orientation changes in android?

If you want to manually handle orientation changes in your app you must declare the "orientation" , "screenSize" , and "screenLayout" values in the android:configChanges attributes. You can declare multiple configuration values in the attribute by separating them with a pipe | character.

What attribute is used to set the screen orientation?

Screen Orientation, also known as screen rotation, is the attribute of activity element in android. When screen orientation change from one state to other, it is also known as configuration change.

How to set portrait and landscape mode in android studio?

There are only two steps to implement the method. Step 1: Open the base UI layout in DESIGN mode so that you see the actual GUI, such as Buttons, icons, etc. Step 2: Click the icon marked in the below screenshot and, from the menu, select Create Landscape Variation.


1 Answers

The <application> element does not support android:screenOrientation. You can tell this by reading the documentation.

As to why it is not supported in the <application> element, I imagine it is at least in part because you should not be using it on many activities, and perhaps not all activities.

For example, your proposed android:screenOrientation="portrait" simply should not be done, pretty much ever. landscape I can understand, for certain types of activities (cameras, video players, some games). But portrait means:

  • You do not want users to be able to use their side-slider hardware keyboards
  • You do not want users to be able to use their tablets in the Android-natural landscape orientation
  • You do not want to run on Google TV

android:screenOrientation should be used only on those activities that absolutely positively have to be in that orientation. Otherwise, please respect your users' wishes as to which orientation to use. Not allowing you to set it for the application as a whole is simply one way to help ensure that you actually think about whether it is needed for a given activity or not.

like image 163
CommonsWare Avatar answered Oct 15 '22 21:10

CommonsWare