gpt4 book ai didi

Android无法检测屏幕旋转

转载 作者:行者123 更新时间:2023-11-30 00:58:56 28 4
gpt4 key购买 nike

我在检测屏幕旋转时遇到问题。我什至尝试添加 android:configChanges="orientation|keyboardHidden"

欢迎任何帮助。

这是我的支票代码:

public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
Log.v("o", "oo");
} else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT){
Toast.makeText(this, "portrait", Toast.LENGTH_LONG).show();
}
}

最佳答案

Caution: Beginning with Android 3.2 (API level 13), the "screen size"also changes when the device switches between portrait and landscapeorientation. Thus, if you want to prevent runtime restarts due toorientation change when developing for API level 13 or higher (asdeclared by the minSdkVersion and targetSdkVersion attributes), youmust include the "screenSize" value in addition to the "orientation"value. That is, you must decalareandroid:configChanges="orientation|screenSize"

来自 https://developer.android.com/guide/topics/resources/runtime-changes.html

关于Android无法检测屏幕旋转,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39736402/

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