android - 为什么配置更改必须监听方向和屏幕尺寸以进行方向更改?

标签 android orientation config

我在某处阅读并做了笔记(忘记来源),启动 android 11 HONEYCOMB,要监听方向变化,你必须做 android:configChanges="orientation|screenSize"。我的问题是为什么你还必须听屏幕尺寸的变化?我的意思是,如果您有一个 400 x 600 像素的平板电脑,并且您改变了方向,则新尺寸将为 600 x 400 像素。谁能解释一下需要听 screenSize 吗?

最佳答案

here :

Note: If your application targets API level 13 or higher (as declared by the minSdkVersion and targetSdkVersion attributes), then you should also declare the "screenSize" configuration, because it also changes when a device switches between portrait and landscape orientations.

onConfigurationChanged()如果 Activity 声明它将处理所有实际更改的配置,则调用该方法。在 Honeycomb 中,orientation 总是伴随着 screenSize(而 screenSize 以前不存在)。因此,如果您只处理 orientation 更改,那么 Activity 将被销毁并重新创建。

还有 here , 更明确一些(但基本上是这个原因)。

关于android - 为什么配置更改必须监听方向和屏幕尺寸以进行方向更改?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24617756/

相关文章:

android - 将Ionic应用程序部署到手机时遇到大麻烦

java - Android中的加密字符串

javascript - 包括调整大小事件的方向更改

android - 如何检查android中所有正在运行的服务?

android:将 Canvas 转换为位图然后保存到SD卡

matrix - 如何找到魔方的方向?

Android:相机预览的屏幕方向/旋转

c# - 使 C# 控制台应用程序识别 .exe.config 文件中手动编辑的更改

java - 在 Java 中重新排列对象(例如,对于 Minecraft NBT 文件)

.net - 配置文件中的 DTD 实体