Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't override colorAccent? #1

Open
0megaD opened this issue Sep 19, 2017 · 3 comments
Open

Can't override colorAccent? #1

0megaD opened this issue Sep 19, 2017 · 3 comments

Comments

@0megaD
Copy link

0megaD commented Sep 19, 2017

I might be missing some nuance due to using this library, but I couldn't figure out how to override colorAccent.

The reason for this is because I want to change the color of the overall datepicker, without propagating those changes throughout the rest of the app.

Am I missing something or does this truly not work:

    <style name="datepicker" parent="Theme.AppCompat.Light.Dialog">
        <item name="colorAccent">#FF0000</item>
    </style>

...

    <com.takisoft.datetimepicker.widget.DatePicker
        android:id="@+id/date_picker"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        style="@style/datepicker"
        />

I also tried setting the style attributes from your readme, with similar results (or a lack of, rather)

An alternative would be to change all the colors of the datepicker manually, but I couldn't figure out the attribute for the selected day indicator, only for the other colored components.

@gregkorossy
Copy link
Owner

Sorry, didn't see this message (apparently GitHub doesn't subscribe me to my own repo automatically...).

Well, the colorAccent is coming from the theme (using ?colorAccent). Maybe try using the theme attribute instead of style? Also, the com.takisoft.datetimepicker.widget.DatePicker is a widget, not a dialog, so you should use Widget.Material.DatePicker or Widget.Material.Light.DatePicker as the parent.

@gregkorossy
Copy link
Owner

Okay, so I checked out the things and here is the situation:
The day selector's color comes from Widget.Material.CalendarView. If you check out out the styles_material.xml file, you'll see that it has a dtp_daySelectorColor attribute that sets it. This is set to ?attr/colorControlActivated by default which gets set from the theme according to the accent color. You can try overriding the chain (style for the DatePicker extending Widget.Material.DatePicker -> set calendarViewStyle to your style extending Widget.Material.CalendarView -> dtp_daySelectorColor) to achieve what you want or set the theme on the DatePicker.

@0megaD
Copy link
Author

0megaD commented Jan 24, 2018

Thanks for your reply, I will try out your suggestions when I have the time. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants