ScrollView disable Auto Scroll To Bottom - Android User Interface

Android examples for User Interface:ScrollView

Description

ScrollView disable Auto Scroll To Bottom

Demo Code


//package com.java2s;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ScrollView;

public class Main {

    public static void disableAutoScrollToBottom(ScrollView scrollView) {
        scrollView/*from w ww . jav a 2 s  .co  m*/
                .setDescendantFocusability(ViewGroup.FOCUS_BEFORE_DESCENDANTS);
        scrollView.setFocusable(true);
        scrollView.setFocusableInTouchMode(true);
        scrollView.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View arg0, MotionEvent arg1) {
                arg0.requestFocusFromTouch();
                return false;
            }
        });
    }
}

Related Tutorials