Webview forces my scrollview from below

I have a webview in scrollview, when the activity loads, it forces my scrollview from below (where the webview is), when the webview ends with "loadData". How can I avoid this? I 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);  
    }  
});  
+5
source share
4 answers

Fhucho's answer is OK to stop the webpage from ending to the end. But you will lose all accessibility with a 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);
    }
}

Hope this helps!

+10
source

Create your own ScrollView using this method:

@Override
public void requestChildFocus(View child, View focused) {
    if (child instanceof WebView) return;
}
+5
source

, , , , WebView XML:

    android:focusable="false"
    android:focusableInTouchMode="false"

, , WebView, . , , , , WebView ScrollView . XML WebView.

+2

Android: descendantFocusability = "blocksDescendants"

0

All Articles