Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 506
gRds Avatar asked Apr 25 '12 10:04

gRds


2 Answers

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>
like image 197
Aerrow Avatar answered Sep 22 '22 06:09

Aerrow


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.

like image 24
Qiang Jin Avatar answered Sep 22 '22 06:09

Qiang Jin