0

The default android spinner just shown a little arrow down. So, I tried to use Widget.Holo.Spinner which show an underline. Here is my style:

<style name="XRSpinner" parent="android:Widget.Holo.Spinner">
    ...
    ...
    ...
</style>

It shows ok on preview, but when I run it, the spinner shown a black background. I have also tried with parent="android:Widget.Holo.Light.Spinner", but it still shows a black background.

Any ideas?

Thanks!


UPDATED

Here is my application manifest

<application
    android:name=".XRWareStock"
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/Theme.AppCompat.Light.NoActionBar" >
    <activity android:name=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

My minSdkVersion is 19 and targetSdkVersion is 25.

azizbekian
  • 60,783
  • 13
  • 169
  • 249
Sam
  • 1,826
  • 26
  • 58

2 Answers2

0

The default android spinner just shown a little arrow down

Holo themes are deprecated; don't worry, you don't have to reinvent the wheel to create a custom spinner layout, there are several solutions like BetterSpiner which makes your life easier. It comes with several styles.

Darish
  • 11,032
  • 5
  • 50
  • 70
  • How can I make custom holo spinner with using style ? I want to incease height of spinner's underline . How can I done it? – Vishal Vaishnav Jul 17 '17 at 13:17
  • @VishalVaishnav refer https://stackoverflow.com/questions/34592451/change-size-of-edittext-bottom-border. This solution will also work for spinner – Darish Jul 17 '17 at 13:34
0

Do you wish to have an underline and/or change the arrow?

For the underline, you can change your style's parent to:

style="@style/Base.Widget.AppCompat.Spinner.Underlined"

So for your style's name:

<style name="XRSpinner" parent="Base.Widget.AppCompat.Spinner.Underlined">

If you want to change the arrow's color:

Java

Spinner spinner = (Spinner) findViewById(R.id.spinner);
spinner.getBackground().setColorFilter(getResources().getColor(R.color.YOUR_COLOR), PorterDuff.Mode.SRC_ATOP);

XML

<Spinner
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:backgroundTint="@color/YOUR_COLOR" />
Joaquim Ley
  • 4,038
  • 2
  • 24
  • 42