Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
394 views
in Technique[技术] by (71.8m points)

screen orientation - 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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...