动态壁纸可以将屏幕锁定为竖屏模式吗?如果有,是怎么做到的?
我应该提到的是,我在SO上看到了这个问题的两个假设答案,一个看起来非常复杂,我不完全理解,答案不被原始发帖者接受。第二个答案不适合我。
第三个答案涉及使用:
android:screenOrientatin = "portrait" or "landscape"
已被建议,但尚不清楚它应该在清单中的确切位置。
EDIT:我试过把android:screenOrientation="portrait"放在manifest中很多不同的地方,但是都没有成功。
EDIT:另一个答案是旋转你的位图,并通过把所有的东西都画向一边来处理旋转——但这看起来很难看,因为当你旋转手机时,操作系统会启动一个旋转动画——这意味着当你转动手机时,你会得到一个可怕的跳跃效果。
我开始怀疑真正的答案仅仅是"不"。
您试过setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
了吗?
在你的AndroidManifest.xml中你应该有这样的内容:
<application
android:icon="@drawable/app_icon"
android:label="@string/nuboLogin"
android:name=".LoginApplication"
android:debuggable="true">
<activity
android:name=".WallPaperActivity"
android:label="@string/wallPaper"
android:windowSoftInputMode="adjustPan"
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" android:screenOrientation="portrait"
android:configChanges="orientation|keyboardHidden">
</activity>
这应该确保你的Activity在纵向模式下运行。如果你喜欢横向,你可以很容易地猜到你应该修改什么
Android应用程序在方向改变时重新启动activity。你可以使用
android:configChanges in your manifest. The activity is shut down and restarted by default, when a configuration change occurs at runtime, but declaring a configuration with this attribute will prevent the activity from being restarted. Instead, the activity remains running and its onConfigurationChanged() method is called.
use android:screenOrientatin = "portrait" or "landscape" it will force the app to run in the mode you specify. However it will not prevent the activity from being shut down and restarted.