How to change DatePicker's CalendarView's background color in Lollipop?

后端 未结 2 753
[愿得一人]
[愿得一人] 2020-12-18 14:14

I worked so hard to change the default background color of Lollipop\'s DatePicker. I cannot simply use Styleable attrs to change the default style. And as mentioned in anoth

相关标签:
2条回答
  • 2020-12-18 14:26

    Any code using reflection may break on future OS updates. You should never use reflection to access private APIs or values.

    The easiest way would be to create an overlay theme that redefines android:colorAccent and apply that to your DatePicker.

    res/values/styles.xml:

    <style name="MyThemeOverlay">
        <item name="android:colorAccent">@color/my_accent</item>
    </style>
    

    res/layout/my_layout.xml:

    <DatePicker
        ...
        android:theme="@style/MyThemeOverlay" />
    
    0 讨论(0)
  • 2020-12-18 14:28

    if you want to do it programmatically without xml, follow this link

    0 讨论(0)
提交回复
热议问题