How do I display a TextArea for my android project? From xml, the only choice is TextField, multi lined. But thats editable. I need a TextArea which is only for displaying messa
Its really simple, write this code in XML:
<EditText
android:id="@+id/fname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="First Name"
/>
Try this:
<EditText
android:id="@+id/edit_text"
android:layout_width="match_parent"
android:layout_height="150dp"
android:inputType="text|textMultiLine"
android:gravity="top"/>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="100dp">
<EditText
android:id="@+id/question_input"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:ems="10"
android:inputType="text|textMultiLine"
android:lineSpacingExtra="5sp"
android:padding="5dp"
android:textAlignment="textEnd"
android:typeface="normal" />
</android.support.v4.widget.NestedScrollView>
<EditText
android:id="@+id/comments_textbox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="comments"
android:inputType="textMultiLine"
android:longClickable="false" />
use it to create multi line text box like textArea in Html
If you do not want to allow user to enter text TextView
is the best option here. Any how you can also add EditText
for this purpose. here is a sample code for that.
This would automatically show scrollbar if there is more text than the specified lines.
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textMultiLine"
android:lines="8"
android:maxLines="10"
android:minLines="6"
android:scrollbars="vertical" />
Edit: Adding attributes below to textView
would make it a textArea
that would not be editable.
android:lines="8"
android:maxLines="10"
android:minLines="6" // optional