问题描述
我在我的布局正常土地和布局正常端口文件夹替代布局和他们是根据我是否在启动器件保持土地或端口被系统正确地调用。我的问题是,当我在旋转后,我相继推出该应用的设备,它会尝试已经显示的视图以某种方式适应新的形势,创造一个烂摊子。
我怎么能告诉系统应该在执行过程中切换到备用布局?
I have alternative layouts in my layout-normal-land and layout-normal-port folders and they are correctly invoked by the system according to if I hold the device in land or port at start. My problem is, when I rotate the device AFTER I have launched the app, it tries to somehow adapt the already displayed view to the new situation, creating a mess.How can I tell the system it should switch to the alternate layout during execution?
一直在试验四周,发现在我不要有机器人:configChanges =keyboardHidden |方向,在OnCreate被再次调用,这给正确的布局,但它不是我想要什么。我不认为这是正常的,是吗?也许错误的Android中的问题(2.3.3)?
Have been experimenting around and found that when I dont have android:configChanges="keyboardHidden|orientation" , oncreate gets called again, which gives the correct layout, but its not what I want to have. I dont think this is normal, is it? Maybe a question of bug in Android (2.3.3.)?
推荐答案
通过包括
android:configChanges="orientation"
在您的清单中你说要处理的方向改变自己。如果你希望系统为您处理,您应该将其删除。
in your manifest you are saying you want to handle orientation changes yourself. You should remove it if you want the system to handle it for you.
自动处理工作非常好。如果你有这样一个特殊的原因,你应该只覆盖它。
The automatic handling works extremely well. You should only override it if you have a specific reason for doing so.
在正常操作(没有上述清单条目),定向开关会导致当前的活动被关闭,然后在新的方向重新加载所有资源和布局从当前活动的资源文件夹重开。该过程遵循的的什么是已知的。
In normal operation (without the above manifest entry), an orientation switch causes the current activity to be closed and then re-opened in its new orientation reloading all resources and layouts from the currently active resource folders. The process follows what is known as the "Activity Lifecycle".
如果您包括上述清单条目,你说,我会处理所有改变自己。不要关闭我的活动,所以它是那么你的责任,从活动中删除所有不必要的布局和布局替换它们,你现在需要为当前方向。
If you include the above manifest entry, you are saying, "I will handle all changes myself. Do not close my activity" so it is then your responsibility to remove all unwanted layouts from the activity and replace them with the layouts you now require for the current orientation.
这篇关于设备方向变化并没有改变布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!