I have a Spinner and I have added items to it by specifying it in the xml. Now I want to mention the padding for the list view that is obtained when we click on the spinner (Note, I want padding for the entire list of item and not each item). Below is the code I use currently:
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@id/an_id"
android_layout_width="match_parent"
android_layout_height="48dp">
<Spinner
android:id="@id/my_id"
android:entries="@array/my_values" />
</FrameLayout>
arrays.xml:
<string-array name="my_values">
<item>1</item>
<item>2</item>
</string-array>
Also, I don't want to do this in the java code, I want to do it using xml file. Is this possible?
Yes it is possible. define a popUpTheme as below.
<Spinner
android:id="@+id/spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:popupTheme="@style/AppTheme.PopupOverlay"
android:textSize="?attr/actionBarSize"
android:dropDownWidth="200dp"
/>
And add this in your styles.xml
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light">
<item name="android:padding">8dp</item>
</style>
and yes it works. cheers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With