How to scroll the edittext inside the scrollview

Solution 1:

Try this..

Add below lines into your EditText

android:overScrollMode="always"
android:scrollbarStyle="insideInset"
android:scrollbars="vertical"

Example

   <EditText
        android:id="@+id/editText1"
        android:layout_width="match_parent"
        android:layout_height="200dp"
        android:layout_marginTop="15dp"
        android:background="#eeeeee"
        android:inputType="textMultiLine"
        android:singleLine="false"
        android:overScrollMode="always"
        android:scrollbarStyle="insideInset"
        android:scrollbars="vertical"
        android:text="Android applications normally run entirely on a single thread by              default the “UI thread” or the “main thread”.
        android:textAppearance="?android:attr/textAppearanceMedium" >
    </EditText>

EDIT

Programmatically

youredittext.setOnTouchListener(new OnTouchListener() {

      public boolean onTouch(View v, MotionEvent event) {
            if (youredittext.hasFocus()) {
               v.getParent().requestDisallowInterceptTouchEvent(true);
               switch (event.getAction() & MotionEvent.ACTION_MASK){
               case MotionEvent.ACTION_SCROLL:
                      v.getParent().requestDisallowInterceptTouchEvent(false);
                      return true;
                }
             }
             return false;
       }
});

Solution 2:

First add this at XML

android:scrollbarStyle="insideInset"
android:scrollbars="vertical" 
android:overScrollMode="always"

Then add the same above "OnTouch" but make it return "false" not "true"

public boolean onTouch(View view, MotionEvent event) {

                    if (view.getId() == R.id.DwEdit) {
                        view.getParent().requestDisallowInterceptTouchEvent(true);
                        switch (event.getAction()&MotionEvent.ACTION_MASK){
                        case MotionEvent.ACTION_UP:
                            view.getParent().requestDisallowInterceptTouchEvent(false);
                            break;
                        }
                    }
                    return false;
}

Solution 3:

Kotlin version

Add the following lines to the EditText in your xml:

android:overScrollMode="always"
android:scrollbarStyle="insideInset"
android:scrollbars="vertical"

Add this to the Activity/Fragment:

myEditText.setOnTouchListener { view, event ->
   view.parent.requestDisallowInterceptTouchEvent(true)
   if ((event.action and MotionEvent.ACTION_MASK) == MotionEvent.ACTION_UP) {
       view.parent.requestDisallowInterceptTouchEvent(false)
   }
   return@setOnTouchListener false
}

Solution 4:

you should use NestedScrollView class. This class support child scrolling inside parent scrolling. This class can be a child or a parent.

<android.support.v4.widget.NestedScrollView         
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="#d6d8d9">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">
        <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:maxLines="512"
                android:text=" your content"/>
        <android.support.v4.widget.NestedScrollView
            android:layout_below="@id/ll_button"
            android:layout_width="match_parent"
            android:layout_height="300dp"
            android:background="#d6d8d9">

            <EditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content" 
                android:text="your content"
                android:maxLines="512"/>    
        </android.support.v4.widget.NestedScrollView>       
    </LinearLayout>

</android.support.v4.widget.NestedScrollView>           

Solution 5:

Use this code it's working

In XML

android:singleLine="false"
android:overScrollMode="always"
android:scrollbarStyle="insideInset"
android:scrollbars="vertical"

In programming

edittext.setOnTouchListener(new View.OnTouchListener() {

    public boolean onTouch(View view, MotionEvent event) {

        if (view.getId() == R.id.edittext) {
            view.getParent().requestDisallowInterceptTouchEvent(true);
            switch (event.getAction() & MotionEvent.ACTION_MASK) {
            case MotionEvent.ACTION_UP:
                view.getParent().requestDisallowInterceptTouchEvent(false);
                break;
            }
        }
        return false;
    }
});