简体   繁体   中英

Android DatePicker Selector Color

So, this question is kind of an extension of this question , I solved the issue with the headerBackground but I realised that I had manually set the theme of my DatePicker in my layout using android:theme="@style/State0DatePickerTheme . But when I removed that line from my XML, the day selector just turned back to white (my accent colour defined in my base theme). Any thoughts on why this is, or how to fix it?

For my purposes, I need to have the theme for DatePicker set in my styles.xml with android:datePickerStyle because I'm setting my theme dynamically in my onCreate() and I can't change the theme of the datePicker in java (at least not that I'm aware of).

So, I figured out how to fix it, I simply created a new theme (which I called State0HistoryTheme ) and then made its parent State0BaseTheme and applied that theme to my entire activity in my onCreate() using setTheme()

This is what my State0HistoryTheme looks like for those curious:

<style name="State0HistoryTheme" parent="State0BaseTheme">
    <item name="colorAccent">@color/state0Dark</item>
</style>

This was able to override the colorAccent that I had set in State0BaseTheme

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM