TextView无法正常工作

时间:2012-12-08 10:46:30

标签: android

我有TextView,文字很长。在图形布局中,它显示精美的包装文本,但是当我运行它时,它不会包装文本。这是我的设计代码

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="15dp"
    android:layout_marginLeft="5dp"
    android:background="#ffffff" >

    <RelativeLayout
        android:id="@+id/layout_title"
        style="@style/dialog_header" >

        <ImageView
            android:id="@+id/image_title"
            style="@style/dialog_header_image"
            android:contentDescription="@string/update_reply"
            android:src="@drawable/compose" />

        <TextView
            android:id="@+id/txt_title"
            style="@style/dialog_header_title"
            android:layout_toRightOf="@+id/image_title" />
    </RelativeLayout>

    <ScrollView
        android:id="@+id/layout_message"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/layout_title"
        android:fadingEdge="none"
        android:fillViewport="true" >

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"

            android:padding="10dp" >

            <TextView
                android:id="@+id/txt_message"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:minHeight="130dp"
                android:text="Don&apos;t work too hard to give yourself the best of everything, instead make a greater effort to give God the best of yourself." />
        </LinearLayout>
    </ScrollView>

    <LinearLayout
        android:id="@+id/button_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/layout_message" >

        <Button
            android:id="@+id/btn_reply"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="@string/reply" />

        <Button
            android:id="@+id/btn_forward"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="@string/forward" />
    </LinearLayout>
</RelativeLayout>

enter image description here

我想展示这个,但它只显示一行

3 个答案:

答案 0 :(得分:0)

删除此

android:minHeight="130dp"

并更改textview的高度值

android:layout_height="XXXdp"

答案 1 :(得分:0)

试试这个

android:text="Don&apos;t work too hard to give yourself the\n best of everything, instead     make a greater\n effort to give God the best of yourself."

答案 2 :(得分:0)

要进行文字换行,请在android:singleLine=false中设置TextView

http://developer.android.com/reference/android/widget/TextView.html#attr_android:singleLine