Home » Android » android – What is the default text padding in spinner

android – What is the default text padding in spinner

Posted by: admin June 15, 2020 Leave a comment


I have a spinner and a textview with style like spinner. I want to align the text in both, but I do not know how much padding the text in the spinner has.

enter image description here

How to&Answers:

One thing that you could find in Android Styles is,

<style name="Widget.Holo.TextView.SpinnerItem" parent="Widget.TextView.SpinnerItem">
    <item name="android:textAppearance">@style/TextAppearance.Holo.Widget.TextView.SpinnerItem</item>
    <item name="android:paddingStart">8dp</item>
    <item name="android:paddingEnd">8dp</item>

It shows padding is 8dp each on start and end.

Note: If 8dp look lesser to you, may be you should also look for padding on spinner itself. Like Padding of Spinner item + Padinng of text = What you want.

Hope it works for you.


Spinner spinner = (Spinner) findViewById(R.id.spinner); 

//simple_spinner_item Specify the spinner TextView

    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
                    R.array.planets_array, android.R.layout.simple_spinner_item);

// simple_spinner_dropdown_item Specify the dropdown item TextView if not set , and the same as simple_spinner_item  



To get paddings from Spinner:

        Spinner spinner = new Spinner(context);

        int leftPadding = spinner.getPaddingLeft();
        int topPadding = spinner.getPaddingTop();
        int rightPadding = spinner.getPaddingRight();
        int bottomPadding = spinner.getPaddingBottom();