I have an expandable listview. The rows consist of a textview and a custom checkbox. The size of the checkbox depends on the textview's text size. There are only two available sizes. When the large checkbox is shown, the difference between the rows is small. When the small checkbox is shown, it looks big. How can I reduce the row height between the rows?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/childlayout"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/relativeLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_centerVertical="true"
android:layout_height="wrap_content"
android:layout_marginLeft="50dp" >
<TextView
android:id="@+id/child_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:gravity="center_vertical"
android:textColor="#000000"/>
</LinearLayout>
<CheckBox
android:id="@+id/multiple_checkbox"
android:layout_width="wrap_content"
android:layout_centerVertical="true"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:checked="true"
android:layout_marginRight="10dp"
android:button="@drawable/productlists_custom_cb"
android:clickable="false"
android:focusable="false"
android:focusableInTouchMode="false" />
</RelativeLayout>
</LinearLayout>
If I set the layout_height of the relative layout to 30dp, the row height will be smaller. But this shouldn't be the way.
This is the .xml for setting the smaller checkbox on and off:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:drawable="@drawable/cbon348" />
<item android:state_checked="false" android:drawable="@drawable/cboff348" />
</selector>
One could think the canvas for the image is much bigger than the image itself, but I assure you, it isn't.
EDIT:
I simplified the code to as below, and still nothing:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/childlayout"
android:orientation="horizontal">
<TextView
android:id="@+id/child_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="50dp"
android:gravity="center_vertical"
android:textColor="#000000"/>
<CheckBox
android:id="@+id/multiple_checkbox"
android:layout_width="wrap_content"
android:layout_gravity="center_vertical"
android:gravity="center_vertical"
android:layout_height="wrap_content"
android:checked="true"
android:layout_marginRight="10dp"
android:button="@drawable/productlists_custom_cb"
android:clickable="false"
android:focusable="false"
android:focusableInTouchMode="false" />
</LinearLayout>
My solution was to create the checkbox images in different sizes then I set the appropriate image according to the screen size:
Try using negative padding on the textview to reduce that space.