我如何锁定屏幕方向的手机,而不是平板电脑? (安卓)
我一直在一个Android项目,这是为了能够同时与Android手机和平板电脑兼容。在平板电脑上的应用程序是伟大的工作,看起来也不错。不过,在手机上,我们已经遇到了问题,以编程方式和布局明智的(采用了10.1英寸屏幕的工作是轻松了许多比4英寸的屏幕)。为了解决这些问题,我们决定关闭屏幕的方向,但只适用于手机的版本,ATLEAST是暂时的。
I have been working on a Android project, that is intended to be compatible with both the Android phones and tablets. On the tablet the app is working great and looks good too. However, on the phone we have been running into issues both programmatically and layout wise (working with a 10.1 inch screen is a lot easier than a 4 inch screen). To solve some of these problems we have decided to deactivate screen orientation but only for the phone version, atleast temporarily.
这个问题很简单,我怎么关闭屏幕方向的Android手机,同时保持积极的Android平板电脑?我知道我可以在manifest文件做到这一点,但是,这也将锁定方向的平板电脑,我相信。
The question is simple, how do I deactivate the screen orientation for Android phone, while keeping it active for the Android tablets? I know I can do this in the manifest file, however, this will also lock the orientation for the tablet I believe.
您可以从应用程序做得一样好。
You can do it from application as well.
锁定屏幕方向(安卓)
http://developer.android.com/reference/android/app/Activity.html#setRequestedOrientation(int)
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
和属性都可以在这里找到:
And attributes can be found here:
http://developer.android.com/reference/android/R.attr.html#screenOrientation