开发者

Android TextView Problem

I have a textview, for some cases it has long text. For long text, it appears so long tha开发者_如何学Ct 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?


You may try to add a lines attribute:

android:lines="4"

Also wrap_content may not be the best choice for the width. Check fill_parent.


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.


You can try to set the android:layout_width = a specific size.


I think setting the gravity to "center" in the xml file might do the job:

    android:gravity="center"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜