scroll EditText - Android User Interface

Android examples for User Interface:EditText

Description

scroll EditText

Demo Code


//package com.java2s;
import android.annotation.SuppressLint;
import android.support.annotation.NonNull;

import android.view.MotionEvent;
import android.view.View;
import android.widget.EditText;

public class Main {
    public static void scrollCompat(@NonNull final EditText editText,
            final int editTextId) {
        editText.setOnTouchListener(new View.OnTouchListener() {
            @SuppressLint("ClickableViewAccessibility")
            @Override/* w w  w.  java2 s.  c  om*/
            public boolean onTouch(final View v, final MotionEvent event) {
                if (v.getId() == editTextId) {
                    v.getParent().requestDisallowInterceptTouchEvent(true);
                    switch (event.getAction() & MotionEvent.ACTION_MASK) {
                    case MotionEvent.ACTION_UP:
                        v.getParent().requestDisallowInterceptTouchEvent(
                                false);
                        break;
                    }
                }
                return false;
            }
        });
    }
}

Related Tutorials