0

i'm trying to make edittext scrollable by using this code

        <EditText
            android:id="@+id/details"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="10dp"
            android:background="@drawable/roundededitetxt"
            android:gravity="center"
            android:hint="@string/txtdetails"
            android:overScrollMode="always"
            android:enabled="true"
            android:focusableInTouchMode="true"
            android:scrollbarStyle="insideInset"
            android:scrollbars="vertical"
            android:editable="true"
            android:clickable="true"
            android:fadeScrollbars="false"                />

and in java

            details.setScroller(new Scroller(getActivity()));
            details.setMaxLines(2);
            details.setVerticalScrollBarEnabled(true);
            details.setVerticalFadingEdgeEnabled(false);

            details.setMovementMethod(new ScrollingMovementMethod());
            details.setOnTouchListener(new View.OnTouchListener() {

                public boolean onTouch(View v, MotionEvent event) {

                    v.getParent().requestDisallowInterceptTouchEvent(true);
                    switch (event.getAction() & MotionEvent.ACTION_MASK) {
                        case MotionEvent.ACTION_UP:
                            v.getParent().requestDisallowInterceptTouchEvent(false);
                            return true;
                    }
                    return false;
                }
            });

the edittext is scrolling fine but i cant type in it any more and the scrollbar is not showing also but i can scroll the text

Radwa Ali
  • 53
  • 3
  • 8

1 Answers1

0

For a vertically scrollable EditText:

android:inputType="textMultiLine"

This works in my apps.

When it doesn't work for you, try these answers : How to make edittext in Android scrollable?

mariachi
  • 135
  • 10