Текст Android TextView, не перенесенный

Кто-либо может сказать мне, что идет не так, как надо с текстом? Текст дольше, чем одна строка не переносится к следующей строке, но идет вне экрана.

Следующее является кодом:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"
    android:orientation="horizontal" 
    android:padding="4dip">

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content"
        android:orientation="vertical" 
        android:padding="4dip">

        <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="fill_parent" 
            android:layout_height="wrap_content"
            android:orientation="horizontal" 
            android:padding="4dip">
            <TextView 
                android:id="@+id/reviewItemEntityName"
                android:layout_width="wrap_content" 
                android:layout_height="wrap_content"
                android:text="event/venue" 
                android:textColor="@color/maroon"
                android:singleLine="true" 
                android:ellipsize="end" 
                android:textSize="14sp"
                android:textStyle="bold" 
                android:layout_weight="1" />

            <ImageView 
                android:id="@+id/reviewItemStarRating"
                android:layout_width="wrap_content" 
                android:layout_height="wrap_content"
                android:layout_alignParentTop="true"
                android:layout_alignParentBottom="true"
                android:src="@drawable/title_1_star" />
        </LinearLayout>

        <TextView 
            android:id="@+id/reviewItemDescription"
            android:layout_width="fill_parent" 
            android:layout_height="wrap_content"
            android:text="Description comes here" 
            android:textSize="12sp" 
            android:layout_weight="1"/>
    </LinearLayout>
</LinearLayout>
74
задан Peter O. 26 September 2014 в 08:44
поделиться

4 ответа

Я сам его исправил, ключ - android:width="0dip"

<LinearLayout 
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:padding="4dip"
    android:layout_weight="1">

    <LinearLayout 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:padding="4dip">

        <TextView
            android:id="@+id/reviewItemEntityName"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textColor="@color/maroon"
            android:singleLine="true"
            android:ellipsize="end"
            android:textSize="14sp"
            android:textStyle="bold"
            android:layout_weight="1" />

        <ImageView
            android:id="@+id/reviewItemStarRating"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_alignParentBottom="true" />
        </LinearLayout>

        <TextView
            android:id="@+id/reviewItemDescription"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:textSize="12sp"
            android:width="0dip" />

    </LinearLayout>

    <ImageView
        android:id="@+id/widget01"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/arrow_nxt"
        android:layout_gravity="center_vertical"
        android:paddingRight="5dip" />

</LinearLayout> 

80
ответ дан 24 November 2019 в 11:54
поделиться

вы должны использовать android:singleLine="false" в тегах TextView.

0
ответ дан 24 November 2019 в 11:54
поделиться

В вашем коде неправильно задан один из параметров макета. В первом TextView

android:layout_width="wrap_content"

измените на

android:layout_width="fill_parent" 

Текст, который за пределами ширины экрана будет обернут к следующей строке и установите android:singleline="false".

4
ответ дан 24 November 2019 в 11:54
поделиться

Я думаю, это зависит от конкретной комбинации макетов на вашем дисплее. Некоторые флаги могут быть переопределены или проигнорированы. У меня есть TabHost с вкладками, каждая вкладка представляет собой список таблиц. Итак, это вкладка ListView, каждая строка которой представляет собой TableLayout TextView. Я попробовал исправления, перечисленные выше, и ни одно из них не сработало.

0
ответ дан 24 November 2019 в 11:54
поделиться
Другие вопросы по тегам:

Похожие вопросы: