Custom Selectors ================ This doc describes how to create custom stateful drawables and colors to be used in the view. ## Stateful-ness in Material CalendarView There are several places in the view where reacting to state would be useful. The most obvious is the date selection indicator, but state can also be represented with custom backgrounds set by decorators or text colors. The state that is used to represent selected days is `android:checked`. Days can also be disabled, which is represented with `android:enabled`. ### Drawables If you want to set a custom selector or background, you'll need to make sure your drawable responds to state. This is most easily done by using a `selector` in your xml or use `StateListDrawable`. Here is a basic example of a selector: ```xml ``` This is the (truncated) code used to generate the default selector: ```java private static Drawable generateSelector() { StateListDrawable drawable = new StateListDrawable(); drawable.setExitFadeDuration(...); drawable.addState(new int[]{android.R.attr.state_checked}, generateCircleDrawable(...)); drawable.addState(new int[]{android.R.attr.state_pressed}, generateCircleDrawable(...)); drawable.addState(new int[]{}, generateCircleDrawable(Color.TRANSPARENT)); return drawable; } ``` ### Text Color In some cases, the default text color isn't the one you want. In this case, you will need to create a custom text appearance style that sets the text color you need. You do this by setting `mcv_dateTextAppearance` or calling `setDateTextAppearance()`. This library provides a text appearance style `TextAppearance.MaterialCalendarWidget.Date`, for you to extend. And it also has two stateful colors, `mcv_text_date_dark` or `mcv_text_date_light` (which is the default). Here's an example for a dark theme and a light selector: ```xml ``` Here's an example for a dark theme and a dark selector: ```xml ``` ```xml ```