Friday, 6 December 2013

Horizontal Scrolling And Problem Of Word Wrap in Edittext in Android

Recently, I was trying to develop some application for Android device, I came across a bug. I had a edittext with inputType set to 'textMultiLine'.
android:inputType="textMultiLine"
The edittext has word wrap on by default. I wanted it off. The following attribute is needed to turn it off.
android:scrollHorizontally="true"
But for me, it was not working as expected. I googled and found out that other were also facing similar problem. After a lot of search and experiment, I got it to work by turning the HorizontallyScrolling on inside the Java Code instead of XML. Probably, this is some bug in the android:scrollHorizontally attribute in XML. The best resolution is to set this property through Java code.
EditText textbox = (EditText) findViewById(R.id.mainEdittext);
textbox .setHorizontallyScrolling(true);

1 comment:

  1. 100% works,..you are the man...salut...

    ReplyDelete