Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android TextView Text not getting wrapped

Can anyone tell me what's going wrong with the text? Text longer than one line doesn't wrap to the next line but goes beyond the screen.

Following is the code:

<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> 
like image 918
d-man Avatar asked Feb 04 '10 06:02

d-man


People also ask

What does Match_parent mean in Android?

MATCH_PARENT means that the view wants to be as big as its parent, minus the parent's padding, if any. Introduced in API Level 8.

What is Ellipsize?

Android Ellipsize Android TextView ellipsize property Causes words in the text that are longer than the view's width to be ellipsized ( means to shorten text using an ellipsis, i.e. three dots …) instead of broken in the middle to fit it inside the given view.


1 Answers

I fixed it myself, the key is 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>  

like image 114
d-man Avatar answered Sep 23 '22 21:09

d-man