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>
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.
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.
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With