Android how to set ScrollBar in Edittext?

Viewed 22489

I want to ScrollText in Edittext and also show Scrollbar at corner. I Scroll the text By Using

questionEntry.setScroller(new Scroller(myContext)); 
questionEntry.setMaxLines(1); 
questionEntry.setVerticalScrollBarEnabled(true); 
questionEntry.setMovementMethod(new ScrollingMovementMethod()); 

Scrolling text works, but the ScrollBar isn't visible. How can I make it visible?

3 Answers

I have checked too options but i think

 android:scrollbars="vertical"

this is best or you can do it by defining multiline

android:inputType="textMultiLine"

or also you can solve this issue by

edittext.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View view, MotionEvent motionEvent) {

            view.getParent().requestDisallowInterceptTouchEvent(true);
            switch (motionEvent.getAction() & MotionEvent.ACTION_MASK){
                case MotionEvent.ACTION_UP:
                    view.getParent().requestDisallowInterceptTouchEvent(false);
                    break;
            }

            return false;
       }

  });
Related