I am trying to design a ListView row layout with the following:
- A check box
- An image
- 3 text items. 2 at the top, 1 at the bottom. Where one of the top text items is right aligned.
- An image
It would look something like this:
Chk Img Left aligned small text Right aligned small text Img
Box Btn1 Left aligned medium text Btn2
No matter what I try, I cannot get the right aligned text to work properly. If I put the 2 top text items into a RelativeLayout and set the 2nd one to android:layout_alignParentRight="true"
it gets aligned to the edge of the row, overlaying the 2nd image. The following is one of my many attempts:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<CheckBox
android:id="@+id/cbSelect"
android:layout_width="wrap_content"
android:layout_height="48dp"
android:layout_alignParentLeft="true"/>
<ImageView
android:id="@+id/imgType"
android:layout_width="wrap_content"
android:layout_height="48dp"
android:layout_toRightOf="@id/cbSelect"
android:src="@android:drawable/btn_star_big_on"/>
<LinearLayout
android:id="@+id/itmDetails"
android:layout_width="wrap_content"
android:layout_height="48dp"
android:layout_toRightOf="@id/imgType"
android:gravity="center_vertical"
android:orientation="vertical"
android:paddingLeft="8dp" >
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/txtTopLeft"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@android:color/black"
android:textSize="12sp"
android:text="Top Left"/>
<TextView
android:id="@+id/txtTopRight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:textColor="@android:color/black"
android:textSize="12sp"
android:text="Top Right"/>
</RelativeLayout>
<TextView
android:id="@+id/txtMain"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Main Item Text"
android:textColor="@android:color/black"
android:textSize="16sp" />
</LinearLayout>
<ImageView
android:id="@+id/imgStar"
android:layout_width="wrap_content"
android:layout_height="48dp"
android:layout_alignParentRight="true"
android:src="@android:drawable/btn_star"/>
</RelativeLayout>
Any suggestions?