Home » Android » android – Scroll inside an EditText which is in a ScrollView

android – Scroll inside an EditText which is in a ScrollView

Posted by: admin May 14, 2020 Leave a comment

Questions:

Is it possible to scroll inside an EditText which is in a ScrollView?

<ScrollView 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">
<LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">
<!-- scroll inside this EditText -->
            <EditText android:id="@+id/et_scrollhere"
                android:lines="6"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:hint="Voorbeeld"
                android:layout_margin="5dp"
                android:scrollbars="vertical"
                android:inputType="textMultiLine"/>
</LinearLayout>
</ScrollView>

Or is it possible to have the EditText embedded in the keyboard in portrait mode? Something like WhatsApp, that EditText is scrollable.

How to&Answers:
EditText dwEdit = (EditText) findViewById(R.id.DwEdit);       
dwEdit.setOnTouchListener(new OnTouchListener() {

                public boolean onTouch(View view, MotionEvent event) {
                    // TODO Auto-generated method stub
                    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;
                }
            });

And in your xml file

      <EditText
        android:id="@+id/DwEdit"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:minLines="10"
        android:scrollbarStyle="insideInset"
        android:scrollbars="vertical" 
        android:overScrollMode="always"
        android:inputType="textCapSentences">
        </EditText> 

I hope it will help you ..