Spinners provide two states. The first and default state (state A) shows the currently selected value. The second (state B) shows a dropdown menu when the spinner display is touched.
By default a left padding is added to the items displayed in state A and B. I would like to remove it when the current selected value is displayed (state A) but to keep it when items are displayed in the dropdown menu (state B).
Since the padding is set with the CheckedTextView used in the layout that is specified when the spinner is created, my first try was to pass to the spinner constructor a custom layout that contains a CheckedTextView with empty padding. This way, the left padding disapears in state A but also in state B. However, my goal was to keep it for state A.
My second try was to customize android:dropDownSpinnerStyle in my theme definition. Since changing background color for android:dropDownSpinnerStyle changes the background color of the item in state A only, my thought was to override the marginLeft or paddingLeft with a negative value. Unfortunately, it has no effect.
Given that negative margin/padding seems not to be taken into account, I have tried the opposite. Firstly, I have used a custom item layout (as explained for my first try) in order to remove left padding on both states (A and B). Secondly, I have defined a custom style for property android:dropDownListViewStyle. Unfortunately, using a positive marginLeft value with the last property has no effect. Thus, I have set paddingLeft. It works and allows me to get the left spacing for state B only. However, the left space applies also to the background touch color (cf. image below).
I think that only the style for state A should be altered if I want to have the on touch background color that fully fills the dropdown menu width. Any idea, suggestion or example is welcomed.
Below is my theme definition for the third try:
<style name="Theme.App.Base" parent="Theme.App">
...
<item name="android:dropDownListViewStyle">@style/Widget.Spinner.DropDown.ListView</item>
</style>
<style name="Widget.Spinner.DropDown.ListView" parent="Widget.AppCompat.ListView.DropDown">
<item name="android:paddingLeft">16dp</item>
</style>