在 Android 上禁用屏幕旋转 [英] Disable screen rotating on Android
本文介绍了在 Android 上禁用屏幕旋转的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我按下按钮时,我希望在我的所有活动中禁用屏幕旋转.我该怎么做?
When I press a button, I would like to disable screen rotation on all my activities. How can I do that?
顺便说一句,当用户点击按钮时,手机可以处于横向或纵向位置.
BTW, the phone can be located in landscape or portrait position when the user click the button.
推荐答案
我找到了解决方案:
在 manifest.xml 中:
in manifest.xml:
<application android:icon="@drawable/icon" android:label="@string/app_name" android:theme="@android:style/Theme.NoTitleBar" android:name="MyApplication">
在 MyApplication.java 中:
in MyApplication.java:
public class UPackingListApplication extends Application {
public void onConfigurationChanged(Configuration newConfig) {
newConfig.orientation = [orientation we wanna to use (according to ActivityInfo class)];
super.onConfigurationChanged(newConfig);
}
}
这篇关于在 Android 上禁用屏幕旋转的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文