gRds
gRds

Reputation: 164

Android EditText with multiple Lines automatic line break

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?

Upvotes: 11

Views: 22819

Answers (2)

Aerrow
Aerrow

Reputation: 12134

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>

Upvotes: 55

Qiang Jin
Qiang Jin

Reputation: 4467

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.

Upvotes: 5

Related Questions