Search code examples
androidxmltextviewmultiline

Android TextView Problem


I have a textview, for some cases it has long text. For long text, it appears so long that so that its distorted the total layout. I want for long text, it should appear in multi-lines. Here is xml for TextView

<TextView
            android:id="@+id/bottomText"
            android:layout_height="wrap_content"
            android:textColor="#FFFFFF"
            android:background="#000000"
            android:textSize="16sp"
            android:layout_gravity="center_horizontal"
            android:text="@string/text_searchword"
            android:layout_width="wrap_content">
</TextView>

What is solution of this problem?


Solution

  • Set the android:lines property like Heiko Rupp points out and also set either android:maxLenght or android:maxEms too.

    Both will limit your TextView either to a maximum of x pixels or density independent pixels or to x ems accordingly.