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); } });
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!
Create your own ScrollView using this method:
@Override public void requestChildFocus(View child, View focused) { if (child instanceof WebView) return; }
, , , , WebView XML:
android:focusable="false" android:focusableInTouchMode="false"
, , WebView, . , , , , WebView ScrollView . XML WebView.
Android: descendantFocusability = "blocksDescendants"