Android: How to clear space between each entry in a Spinner?

Asked

Viewed 80 times

0

I have a spinner where I intend to name the horoscopes. However, the name of horoscopes appears with a blank line separating each horoscope when I "open" the spinner. Something like this:

-linha em branco-
Geminis
-linha em branco-
Cancer
-linha em branco-

Can anyone tell me how I can narrow the gap between the names of each horoscope? This is my code:

strings.xml

<string-array name="horoscope_array">
        <item>Aquarius</item>
        <item>Pisces</item>
        <item>Aries</item>
        <item>Taurus</item>
        <item>Gemini</item>
        <item>Cancer</item>
        <item>Leo</item>
        <item>Virgo</item>
        <item>Libra</item>
        <item>Scorpius</item>
        <item>Sagitarius</item>
        <item>Capricorn</item>
    </string-array>

<string name="horoscope_prompt">Choose a Horoscope</string>

In my layout.xml have:

<Spinner
android:layout_height="35dp"
android:id="@+id/spinner1"
android:layout_width="match_parent"
android:entries="@array/horoscope_array"
android:textColor="@color/orange"
android:prompt="@string/horoscope_prompt" />
  • 1

    Blank line?

1 answer

0

Look, there it seems to be all right, but I don’t know how this your class, but it must be something like this

Spinner spinner;

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.teuLayout);        
    spinner = (Spinner)findViewById(R.id.spinner);

    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.horoscope_array, android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);

}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.