Change android numberpicker divider color

Anurag picture Anurag · Sep 14, 2013 · Viewed 11.6k times · Source

enter image description here

I want to change the divider color(blue) of numberpicker shown above to transparent. I tried a lot of things like

number_picker.setDividerDrawable(getResources().getDrawable(R.color.transparent));
number_picker.setShowDividers(NumberPicker.SHOW_DIVIDER_NONE);

I also tried settings android:divider in xml But none of them worked

Then I tried setting it using styles, but when I put the following entry in my styles, it says minimum version required is 14 and my app has minimum version 11

<style name="AppTheme" parent="@android:style/Widget.DeviceDefault.DatePicker">
    <!-- All customizations that are NOT specific to a particular API-level can go here. -->
    <item name="android:divider">@color/transparent</item>
</style>

Can anyone suggest how can I achieve this?

Answer

Rubin Yoo picture Rubin Yoo · May 15, 2017

This worked for me without using the reflection.

my_layout.xml

<NumberPicker
   ...
   android:theme="@style/DefaultNumberPickerTheme" />

Styles.xml (AppTheme is my app theme in the app)

<style name="DefaultNumberPickerTheme" parent="AppTheme">
        <item name="colorControlNormal">@color/dividerColor</item>
</style>

From https://stackoverflow.com/a/43985361/1915831