当方向改变时保存滚动视图的位置 [英] Save the position of scrollview when the orientation changes

查看:23
本文介绍了当方向改变时保存滚动视图的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的布局:

我需要在方向改变时保存滚动位置.例如,如果屏幕在纵向模式下显示从中间名开始的布局,则在横向模式下应该从中间名开始.

I need to save the scrolling position when the orientation changes. for example if the screen shows layout starting from middle name in portrait mode,it should start from same in the landscape mode.

推荐答案

你 如果你的 Activity 没有在轮换时改变任何东西,你可以使用android:configChanges="orientation|keyboardHidden|screenSize" 在此特定活动的清单文件中.但这显然是解决方法,而不是正确的解决方案.

You If your activity is not changing anything on rotation you can use android:configChanges="orientation|keyboardHidden|screenSize" in manifest file within this particular activity. But this is clearly workaround and not a proper solution.

注意:

如果您需要为横向和纵向使用不同的视图,或者如果您需要为不同的设备使用不同的视图,则应使用 bundle 并将数据保存在saveinstancestate 中,并在 oncreate 中检索数据.此方法停止重新创建活动,活动假设事情将由用户自己处理.

这篇关于当方向改变时保存滚动视图的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆