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

Date Color Customization #469

Open
mohitrajput987 opened this issue Sep 1, 2017 · 1 comment
Open

Date Color Customization #469

mohitrajput987 opened this issue Sep 1, 2017 · 1 comment

Comments

@mohitrajput987
Copy link

How can I customize date colors for both enabled and disabled date?
As per the current style customization, if I set any color, it reflects in disabled/outer dates also.

I want black color on current month's date and gray color on other months' dates which are displayed in the current month.

@mfc92
Copy link

mfc92 commented Jul 5, 2018

First of all, you must create a new selector in drawable, like this one: https://github.com/roomorama/Caldroid/blob/master/caldroid/src/main/res/color/cell_text_color.xml

Then, you have to override Caldroid's theme creating your own theme in your styles.xml. It should be something like this:

    <!-- Calendar theme. -->
    <style name="CaldroidCustom" parent="CaldroidDefault">
        <item name="styleCaldroidNormalCell">@style/CaldroidCustomNormalCell</item>
        <item name="styleCaldroidSquareCell">@style/CaldroidCustomSquareCell</item>
    </style>

    <style name="CaldroidCustomCell" parent="CaldroidDefaultCell">
        <item name="android:textColor">@drawable/cell_text_color</item>
    </style>

    <style name="CaldroidCustomNormalCell" parent="CaldroidCustomCell">
        <item name="android:padding">5dp</item>
    </style>

    <style name="CaldroidCustomSquareCell" parent="CaldroidCustomCell" />

Finally, add your new theme to calendar:

caldroidFragment = new CaldroidFragment();
caldroidFragment.setThemeResource(R.style.CaldroidCustom);

I hope it helps! :)

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