androidandroid-number-picker

Set line color in component


How to set NumberPicker horizontal lines to white in layout xml?

enter image description here


Solution

  • Create a custom theme for the NumberPicker.

    Create a styles.xml file in res/values folder, if it doesn't exist and define a theme for number picker. Define colorControlNormal attribute to required color.

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
        <style name="NumberPickerTheme" parent="Theme.AppCompat">
            <item name="android:colorControlNormal">#FF0000</item> 
        </style>
    </resources>
    

    Apply the theme to your NumberPicker.

    <NumberPicker
            android:theme="@style/NumberPickerTheme"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />