gpt4 book ai didi

android:screenOrientation ="portrait"在 Jellybean 中被忽略

转载 作者:太空宇宙 更新时间:2023-11-03 10:24:54 26 4
gpt4 key购买 nike

android:screenOrientation="portrait"在 Jellybean 中被忽略。如果我 Handlebars 机变成横屏,它无论如何都会改变方向。我试过好几部手机。我必须使用任何新标志吗?

最佳答案

您可以尝试以编程方式进行,

@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
switch (newConfig.orientation)
{
case Configuration.ORIENTATION_PORTRAIT:
// taking action on event
lockScreenRotation(Configuration.ORIENTATION_PORTRAIT);
break;
case Configuration.ORIENTATION_LANDSCAPE:
// taking action on event
lockScreenRotation(Configuration.ORIENTATION_LANDSCAPE);
break;
case Configuration.ORIENTATION_SQUARE:
// taking action on event
lockScreenRotation(Configuration.ORIENTATION_SQUARE);
break;
default:
throw new Exception("Unexpected orientation!!!");
break;
}




private void lockScreenRotation(int orientation)
{
// Stop the screen orientation changing during an event
switch (orientation)
{
...
case Configuration.ORIENTATION_PORTRAIT:
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
break;
case Configuration.ORIENTATION_LANDSCAPE:
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
break;
...
case default:
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
break;
}
}

关于android:screenOrientation ="portrait"在 Jellybean 中被忽略,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13844577/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com