0

If the text is longer than the space allowed by LinearLayout, I want the text to multi line, as shown in the top section of the image below. This is what happens when I run the app on my phone (HTC Desire HD), but when I run it on my tablet (Toshiba Thrive), it gets elipsized, as shown in the bottom section of the image:

what I want on top, what happens on bottom

I have a ListView that consists of rows. Each row is defined as below:

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

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_weight="1"
        android:layout_width="0dip"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <TextView
            android:textStyle="bold"
            android:id="@+id/codeLabel"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content">
        </TextView>
        <TextView
            android:id="@+id/code"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content">
        </TextView>
    </LinearLayout>

    <TextView
        android:id="@+id/description"
        android:layout_weight="3"
        android:layout_width="0dip"
        android:layout_height="wrap_content"
        />   

 </LinearLayout>

How do I fix this?

Umar Qureshi
  • 5,985
  • 2
  • 30
  • 40
Kalina
  • 5,504
  • 16
  • 64
  • 101
  • Have you tried this: http://stackoverflow.com/questions/4152726/how-to-wrap-text-to-next-line-in-android-textview?rq=1 – brthornbury Aug 15 '12 at 17:34
  • @Mozoby I tried using android:scrollHorizontally="false" on its own and that didn't work, but using it with android:inputType="textMultiLine" did the trick! However, this line has a yellow squiggle under it that gives me the warning "Attribute android:inputType should not be used with : Change element type to ?" – Kalina Aug 15 '12 at 18:50

1 Answers1

-1

I had tried them individually and failed, but together

android:scrollHorizontally="false"
android:inputType="textMultiLine"

did the trick... though I get the warning that "inputType" should not be used with TextView.

Kalina
  • 5,504
  • 16
  • 64
  • 101