android:screenOrientation tag in application does not work

只谈情不闲聊 提交于 2019-11-27 16:16:31

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/5062722/androidscreenorientation-tag-in-application-does-not-work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!