webview迫使我的滚动视图到底部 [英] webview is forcing my scrollview to the bottom

查看:110
本文介绍了webview迫使我的滚动视图到底部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在滚动视图中有一个Web视图,当活动"加载时,一旦Web视图完成"loadData",它将迫使我的滚动视图到达底部(该Web视图所在的位置). 如何避免这种情况发生? 我已经尝试过了,但是它在屏幕上跳了下来,我不希望这样:

I have a webview in a scrollview, when the Activity loads, it forces my scrollview to the bottom (where the webview is) once the webview finishes "loadData". How do I keep this from happening? I've tried this, but it jumps the screen up and down, which I don't want:

ScrollView scroll = (ScrollView)findViewById(R.id.detailsScroll);  
scroll.post(new Runnable()   
{  
    @Override  
    public void run()   
    {  
       ScrollView scroll = (ScrollView)findViewById(R.id.detailsScroll);  
       scroll.fullScroll(ScrollView.FOCUS_UP);  
    }  
});  

推荐答案

fhucho的回答可以阻止Webview滚动到底部.但是您将失去轨迹球等所有的可访问性.所以我发现了一个改进:

The answer of fhucho is OK for stoping the webview from scrolling to bottom. But you will lose all accessibility with trackball, etc. So I found an improvement :

public class MyScrollView extends ScrollView {

    @Override 
    public void requestChildFocus(View child, View focused) { 
        if (focused instanceof WebView ) 
           return;
    super.requestChildFocus(child, focused);
    }
}

希望有帮助!

这篇关于webview迫使我的滚动视图到底部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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