How to prevent a ScrollView from scrolling to a WebView after data is loaded?

Standard

You should create new class extend ScrollView, then Override requestChildFocus:

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.webkit.WebView;
import android.widget.ScrollView;

public class MyScrollView extends ScrollView {

 public MyScrollView(Context context, AttributeSet attrs, int defStyle) {
 super(context, attrs, defStyle);
 // TODO Auto-generated constructor stub
 }

 public MyScrollView(Context context, AttributeSet attrs) {
 super(context, attrs);
 // TODO Auto-generated constructor stub
 }

 public MyScrollView(Context context) {
 super(context);
 // TODO Auto-generated constructor stub
 }

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

Leave a Reply

Your email address will not be published. Required fields are marked *