I have created an ExpandableListView with the following code:
<ExpandableListView
android:id="@+id/android:list"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginTop="5dp"
android:layout_weight="1"
android:cacheColorHint="#00000000" /> <!-- This last line fixes a bug with a black background when scrolling through the list -->
The xml that defines the parent row is:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/childname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="40dp"
android:textSize="20sp" />
</LinearLayout>
And finally, the xml that defines the child row is:
<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="1" >
<TextView
android:id="@+id/childname"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="60dp"
android:layout_weight="0.80"
android:focusable="false"
android:textSize="14sp" />
<CheckBox
android:id="@+id/check1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_weight="0.2"
android:focusable="false" />
</LinearLayout>
What I am trying to accomplish is to have the CheckBox to the very right of the screen.
During design time, in eclipse, the element is actually to the right. But when I install it in my phone, it is not.
Here is the screenshot of the result: http://img444.imageshack.us/img444/584/97598265.png
Any ideas what might be wrong?
Regards,
Felipe
UPDATE
Following recommendation, this is what I did to have it working:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/childname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="60dp"
android:focusable="false"
android:layout_centerVertical="true"
android:textSize="14sp" />
<CheckBox
android:id="@+id/check1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:focusable="false" />
</RelativeLayout>
Use a relativeLayout for proper alignment