Android 方向改变时视图重新创建
我想做一些类似于 iPhone 开发的事情:手动重新定位控件而不重新创建整个视图。 这种方法的优点和缺点是什么?
I want to do something like in iPhone development: reposition controls manually without recreating the whole view.
what are pros and cons of this approach?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
希望这对某人有用。
如果您不想在方向更改上重新创建视图,您唯一需要的就是更改清单文件中相应的 Activity,如下所示:
如果您想手动重新定位控件,请覆盖 onConfigurationChanged 并重新定位您需要的所有内容
Hopefully this will be useful for somebody.
if you don't want ro re-create your view on orientation change, the only thing you need is to change corresponding Activity in manifest file like this:
if you want to reposition controls manually, override onConfigurationChanged and reposition everything you need there