Jase Whatson
Jase Whatson

Reputation: 4207

Android EditText keyboard newline not working (only on input view)

In the affirmation text field I press the newline button and it puts spaces. However after I click done the field actually has the correct new lines (second screen capture).

Its not a problem with the device as it works correctly for the compose mail filed in the gmail app. Which is how I would like this to work.

W

enter image description here

<TextView
        android:inputType="textMultiLine"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dip"
        android:text="@string/edit_affimation"
/>
<EditText
android:id="@+id/affText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text=""
android:textSize="18sp"
android:singleLine="false"
>
</EditText>

Upvotes: 13

Views: 10525

Answers (2)

Jase Whatson
Jase Whatson

Reputation: 4207

Figured it out

<EditText
    android:inputType="textMultiLine"
    android:id="@+id/affText"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text=""
    android:textSize="18sp"
    android:singleLine="false">
</EditText>

Add following attribute:

android:inputType="textMultiLine"

Upvotes: 28

fergerm
fergerm

Reputation: 241

You can also do it programmatically:

Editext txt = (EditText) findViewById(R.id.affText);
txt.setRawInputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE);

Upvotes: 6

Related Questions