Sunday, October 21, 2012

How to prevent a scrollview from scrolling to a webview after data is loaded?

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

 
public class MyScrollView extends ScrollView {

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

Then in your xml layout, using:
<MyScrollView 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@color/background" >

The ScrollView will not auto scroll to the WebView anymore.

 

Solution taken from :

http://stackoverflow.com/questions/9842494/how-to-prevent-a-scrollview-from-scrolling-to-a-webview-after-data-is-loaded

 

No comments:

Post a Comment