11

is it possible to have an EditText with multiple Lines which automatically makes a Line break after every 20th Character the user is typing in?

Nimantha
  • 6,405
  • 6
  • 28
  • 69
gRds
  • 164
  • 1
  • 2
  • 7
  • Possible duplicate of [EditText automatically go to a new line](http://stackoverflow.com/questions/23123833/edittext-automatically-go-to-a-new-line) – Uilque Messias May 24 '16 at 19:23

2 Answers2

52

In your XML file create the edittext like this,

 <EditText
        android:id="@+id/editText1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:ems="10"
        android:inputType="textMultiLine" >

        <requestFocus />
    </EditText>
Aerrow
  • 12,086
  • 10
  • 56
  • 90
5

You can implement TextWatcher interface and implement method afterTextChanged. The method will be invoked after text changed, so you can add the line breaks in it by yourself.

Qiang Jin
  • 4,427
  • 19
  • 16