我在某处阅读并做了笔记(忘记来源),启动 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
andtargetSdkVersion
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/