roomorama / Caldroid

A better calendar for Android

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Date Color Customization

mohitrajput987 opened this issue · comments

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.

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! :)