有没有办法为 Android 设备设置初始方向
您好,我想将设备的初始方向设置为纵向模式。但在用户开始使用应用程序后,他们可以更改方向。
我发现的所有示例都只是设置为一个方向,以后无法更改。
谢谢
更新:这就是我为了解决这个问题所做的修复
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
super.loadUrl("file:///android_asset/www/index.html");
OrientationThread orthread = new OrientationThread(this);
orthread.start();
class OrientationThread extends Thread {
DroidGap droidGap;
OrientationThread(DroidGap dGap) {
droidGap = dGap;
}
public void run() {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
//e.printStackTrace();
}
synchronized(droidGap){
droidGap.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
}
}
Hi I want to set an initial orientation for the device to be portrait mode. but after the user starts playing with the app they can change the orientation.
all the examples i found are just the set to one oriention which cannot be later change.
Thanks
UPDATE: This is what i did to fix to get around this
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
super.loadUrl("file:///android_asset/www/index.html");
OrientationThread orthread = new OrientationThread(this);
orthread.start();
class OrientationThread extends Thread {
DroidGap droidGap;
OrientationThread(DroidGap dGap) {
droidGap = dGap;
}
public void run() {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
//e.printStackTrace();
}
synchronized(droidGap){
droidGap.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为这就是您正在寻找的方法:
setRequestedOrientation ()
希望这有帮助!
I think this is the method you're looking for:
setRequestedOrientation()
Hope this helps!