Material-calendarview: Setting selected day label color

Created on 23 Oct 2017  路  5Comments  路  Source: prolificinteractive/material-calendarview

Hi.

I'm trying to set custom selection behaviour for my calendar in app, and I struggle with making the labels to stay the same and make a small ring around it appear. I've managed to set selection color to transparent, but the label also turns white and it's invisible like this.
Is there any way to set selected day label color?

Most helpful comment

You can just provide your own text appearance for the cells:

app:mcv_dateTextAppearance="@style/CustomTextAppearance"

with

    <style name="CustomTextAppearance" parent="TextAppearance.AppCompat.Medium">
        <item name="android:textColor">@color/mcv_text_date_light</item>
        <item name="fontFamily">@font/shirkhand</item>
    </style>

and mcv_text_date_light.xml:

<selector xmlns:android="http://schemas.android.com/apk/res/android"
    android:enterFadeDuration="@android:integer/config_shortAnimTime"
    android:exitFadeDuration="@android:integer/config_shortAnimTime">

    <item android:state_checked="true"
        android:color="@android:color/white" />

    <item android:state_pressed="true"
        android:color="@android:color/white" />

    <item android:state_enabled="false"
        android:color="#808080" />

    <item android:color="@android:color/black" />
</selector>

All 5 comments

Having the same issue.

I've used:

setSelectionColor() on the MaterialCalendarView, and setSelectionDrawable() on my Decorator, both seem to be ignored.

Ah. So the solution that worked for me was to add view.addSpan(new ForegroundColorSpan(Color.BLACK)) to my decorator.

You can just provide your own text appearance for the cells:

app:mcv_dateTextAppearance="@style/CustomTextAppearance"

with

    <style name="CustomTextAppearance" parent="TextAppearance.AppCompat.Medium">
        <item name="android:textColor">@color/mcv_text_date_light</item>
        <item name="fontFamily">@font/shirkhand</item>
    </style>

and mcv_text_date_light.xml:

<selector xmlns:android="http://schemas.android.com/apk/res/android"
    android:enterFadeDuration="@android:integer/config_shortAnimTime"
    android:exitFadeDuration="@android:integer/config_shortAnimTime">

    <item android:state_checked="true"
        android:color="@android:color/white" />

    <item android:state_pressed="true"
        android:color="@android:color/white" />

    <item android:state_enabled="false"
        android:color="#808080" />

    <item android:color="@android:color/black" />
</selector>

And we need to put mcv_text_date_light.xml in color directory of res res/color/mcv_text_date_light.xml of project.

I want to set a ForegroundSpan to a day (only today) and make it white when selected. Setting text appearance doesn't seem to work in this case. Is it possible?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

SamBob01 picture SamBob01  路  3Comments

chuks picture chuks  路  6Comments

fahimk picture fahimk  路  4Comments

TokyoAndroid picture TokyoAndroid  路  4Comments

yuanliu666 picture yuanliu666  路  4Comments