Search code examples
androidcolorsdatepickerdivider

Change Divider Color Android DatePicker Dialog


I´m tying to change the divider color of the DatePicker Dialog.

I create the style:

<style name="dialog_custom" parent="@android:style/Widget.DatePicker">
        <item name="android:divider">@drawable/dialog_divider</item>
    </style>

And create the drawable like this

And the result is this

The divider no change color and the dialog take the content size..


Solution

  • You can do this using theme. Check accepted answer on this question. i think it will helpful to you.

    UPDATES

    Expand res folder in your application and expand values folder. Then create themes.xml file on values folder. then replace all code in themes.xml file with below code.

    <?xml version="1.0" encoding="utf-8"?>
    <resources xmlns:android="http://schemas.android.com/apk/res/android">
    
        <style name="MYTheme" parent="@android:style/Theme">
    
           <item name="android:divider">@drawable/dialog_divider</item>
    
        </style>
    
    </resources>
    

    Then open your AndroidManifest.xml file. and find android:theme and replcae with android:theme="@style/MYTheme"