I have a listview that has a small and a long textview (with varying texts in both) on the left and an imageview on the far right. Problem is that when the long textview gets too long it compresses the imageview on the right before wrapping into a 2nd line. Since both textviews have various lengths in each line, I cannot set a fix dp value for their length. What can I do that the imageview does not get compressed ?
PS: I create the rows in the listview like this:
<TextView
android:id="@+id/info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="10sp"
android:layout_gravity="center_vertical"/>
<TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="12sp"
android:layout_gravity="center_vertical"/>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView
android:id="@+id/image"
android:layout_width="45dp"
android:layout_height="45dp"
android:layout_alignParentRight="true"
android:focusable="false"/>
</RelativeLayout>
Add android:toLeftOf=”@+id/image” to your TextViews. You may need to set the layout_width of the TextViews to fill_parent.