I’ve asked this question before but didn’t know what the exact problem was until now. My problem is that I have made a custom spinner/adapter and I set the padding to 5dip in order to decent spacing in the rows of the spinner. The problem is when I add the padding the I have to make the spinner larger to compensate the more padding. Is there a way that I can ignore the padding for the selected item. So when the spinner is collapsed the padding is ignored and when it is expanded the padding is used.
The xml for the rows in the spinner:
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TableRow
android:id="@+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dip">
<ImageView
android:layout_width="32sp"
android:src="@drawable/icon"
android:id="@+id/spinnerimage"
android:layout_height="32sp" />
<TextView
android:textSize="22sp"
android:textStyle="bold"
android:textColor="#000"
android:layout_width="fill_parent"
android:id="@+id/category"
android:layout_height="wrap_content"
android:paddingLeft="5sp" />
</TableRow>
</TableLayout>
and the spinner:
<Spinner
android:id="@+id/catspinner"
android:layout_marginLeft="25dip"
android:layout_marginRight="25dip"
android:layout_width="fill_parent"
android:layout_centerHorizontal="true"
android:layout_height="wrap_content"
android:prompt="@string/prompt"
android:background="@drawable/yellow_btn"
android:layout_centerVertical="true"
android:drawSelectorOnTop="true" />
If you are using the default drawables, you can’t change the padding the way you’re asking to.
You will have to create your own ninepatch drawables and include them in your app in order to override the behavior of the default drawables.