【发布时间】:2011-06-09 11:48:57
【问题描述】:
我有一个这样的视图层次结构,一个垂直的 ScrollView 和一个包含两个孩子的垂直 LinearLayout:
ScrollView ->orientation:vertical, width:fill_parent, height: fill_parent
LinearLayout -> orientation:vertical, width:fill_parent, height: fill_parent
WebView -> width:fill_parent, height: fill_parent
GoogleAdView -> width:wrap_content, height:wrap_content
当滚动到 webview 的底部并单击那里的任何链接时,尽管页面加载,滚动条仍停留在底部而不是移动到顶部。我可以使用scroll.fullScroll(ScrollView.FOCUS_UP) 以编程方式设置滚动条,但这会导致滚动条明显向上跳跃。我曾尝试在使用scrollView.setVerticalScrollBarEnabled(false) 加载页面之前隐藏滚动条,然后在调用scroll.fullScroll(ScrollView.FOCUS_UP) 之前在页面加载后重新启用它,但这仍然会导致滚动条“跳跃”。
WebView 本身可以更好地处理页面更改时的滚动,看起来它隐藏了滚动条,然后在加载后使其显示在页面顶部。有没有办法使用 ScrollView 来维护它?
【问题讨论】:
标签: android android-webview android-scrollview