3

动态壁纸可以在纵向模式下锁定屏幕吗?如果是这样,怎么办?

我应该提一下,我在 SO 上看到了这个问题的两个假设答案,一个看起来非常复杂,我没有完全理解,并且原始发布者不接受答案。第二个答案对我不起作用。

第三个答案涉及使用:

android:screenOrientatin = "portrait" or "landscape"

已被建议,但尚不清楚这应该在清单中的确切位置。

编辑:尝试将 android:screenOrientation="portrait" 放在清单中的许多不同位置,但没有一个起作用。

编辑:另一个答案是旋转您的位图并通过将所有内容横向绘制来处理旋转-但这看起来很丑陋,因为当您旋转手机时,操作系统会启动旋转动画-这意味着您会得到可怕的跳跃效果转动电话。

4

4 回答 4

2

我开始怀疑真正的答案只是“不”。

于 2013-05-02T13:59:08.823 回答
0

你试过了setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);吗?

于 2013-04-26T19:48:29.330 回答
0

在你的 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 以纵向模式运行。如果您更喜欢横向,您可以轻松猜出您应该修改什么

于 2013-05-02T09:18:28.113 回答
0

当方向改变时,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.
于 2013-05-03T06:37:05.070 回答