DayViewDecorator

public abstract class DayViewDecorator
extends Object implements Parcelable

java.lang.Object
   ↳ com.google.android.material.datepicker.DayViewDecorator


A decorator which allows customizing the day of month views within a MaterialDatePicker.

Summary

Inherited constants

Public constructors

DayViewDecorator()

Public methods

ColorStateList getBackgroundColor(Context context, int year, int month, int day, boolean valid, boolean selected)

Override this method to return a custom color to be applied to the background drawable of the day view corresponding to the provided date.

Drawable getCompoundDrawableBottom(Context context, int year, int month, int day, boolean valid, boolean selected)

Override this method to return a bottom compound drawable for the day view corresponding to the provided date.

Drawable getCompoundDrawableLeft(Context context, int year, int month, int day, boolean valid, boolean selected)

Override this method to return a left compound drawable for the day view corresponding to the provided date.

Drawable getCompoundDrawableRight(Context context, int year, int month, int day, boolean valid, boolean selected)

Override this method to return a right compound drawable for the day view corresponding to the provided date.

Drawable getCompoundDrawableTop(Context context, int year, int month, int day, boolean valid, boolean selected)

Override this method to return a top compound drawable for the day view corresponding to the provided date.

CharSequence getContentDescription(Context context, int year, int month, int day, boolean valid, boolean selected, CharSequence originalContentDescription)

Override this method to return the day view's content description.

ColorStateList getTextColor(Context context, int year, int month, int day, boolean valid, boolean selected)

Override this method to return a custom color to be applied to the text of the day view corresponding to the provided date.

void initialize(Context context)

Optionally override this method to do any initializing for your DayViewDecorator instance.

Inherited methods

Public constructors

DayViewDecorator

public DayViewDecorator ()

Public methods

getBackgroundColor

public ColorStateList getBackgroundColor (Context context, 
                int year, 
                int month, 
                int day, 
                boolean valid, 
                boolean selected)

Override this method to return a custom color to be applied to the background drawable of the day view corresponding to the provided date.

Parameters
context Context: The context of the day view

year int: The year number corresponding to the day view (see ERROR(/java.util.Calendar.YEAR))

month int: The month number (0-11) corresponding to the day view (see ERROR(/java.util.Calendar.MONTH))

day int: The day of month number corresponding to the day view (see ERROR(/java.util.Calendar.DAY_OF_MONTH))

valid boolean: Boolean for whether the day view is in a valid state (if not valid, the day view will likely look and behave disabled)

selected boolean: Boolean for whether the day view is in a selected state (if selected, the day view will likely have a filled color background)

Returns
ColorStateList The background color ColorStateList or null

getCompoundDrawableBottom

public Drawable getCompoundDrawableBottom (Context context, 
                int year, 
                int month, 
                int day, 
                boolean valid, 
                boolean selected)

Override this method to return a bottom compound drawable for the day view corresponding to the provided date.

Parameters
context Context: The context of the day view

year int: The year number corresponding to the day view (see ERROR(/java.util.Calendar.YEAR))

month int: The month number (0-11) corresponding to the day view (see ERROR(/java.util.Calendar.MONTH))

day int: The day of month number corresponding to the day view (see ERROR(/java.util.Calendar.DAY_OF_MONTH))

valid boolean: Boolean for whether the day view is in a valid state (if not valid, the day view will likely look and behave disabled)

selected boolean: Boolean for whether the day view is in a selected state (if selected, the day view will likely have a filled color background)

Returns
Drawable The bottom compound drawable or null

getCompoundDrawableLeft

public Drawable getCompoundDrawableLeft (Context context, 
                int year, 
                int month, 
                int day, 
                boolean valid, 
                boolean selected)

Override this method to return a left compound drawable for the day view corresponding to the provided date.

Parameters
context Context: The context of the day view

year int: The year number corresponding to the day view (see ERROR(/java.util.Calendar.YEAR))

month int: The month number (0-11) corresponding to the day view (see ERROR(/java.util.Calendar.MONTH))

day int: The day of month number corresponding to the day view (see ERROR(/java.util.Calendar.DAY_OF_MONTH))

valid boolean: Boolean for whether the day view is in a valid state (if not valid, the day view will likely look and behave disabled)

selected boolean: Boolean for whether the day view is in a selected state (if selected, the day view will likely have a filled color background)

Returns
Drawable The left compound drawable or null

getCompoundDrawableRight

public Drawable getCompoundDrawableRight (Context context, 
                int year, 
                int month, 
                int day, 
                boolean valid, 
                boolean selected)

Override this method to return a right compound drawable for the day view corresponding to the provided date.

Parameters
context Context: The context of the day view

year int: The year number corresponding to the day view (see ERROR(/java.util.Calendar.YEAR))

month int: The month number (0-11) corresponding to the day view (see ERROR(/java.util.Calendar.MONTH))

day int: The day of month number corresponding to the day view (see ERROR(/java.util.Calendar.DAY_OF_MONTH))

valid boolean: Boolean for whether the day view is in a valid state (if not valid, the day view will likely look and behave disabled)

selected boolean: Boolean for whether the day view is in a selected state (if selected, the day view will likely have a filled color background)

Returns
Drawable The right compound drawable or null

getCompoundDrawableTop

public Drawable getCompoundDrawableTop (Context context, 
                int year, 
                int month, 
                int day, 
                boolean valid, 
                boolean selected)

Override this method to return a top compound drawable for the day view corresponding to the provided date.

Parameters
context Context: The context of the day view

year int: The year number corresponding to the day view (see ERROR(/java.util.Calendar.YEAR))

month int: The month number (0-11) corresponding to the day view (see ERROR(/java.util.Calendar.MONTH))

day int: The day of month number corresponding to the day view (see ERROR(/java.util.Calendar.DAY_OF_MONTH))

valid boolean: Boolean for whether the day view is in a valid state (if not valid, the day view will likely look and behave disabled)

selected boolean: Boolean for whether the day view is in a selected state (if selected, the day view will likely have a filled color background)

Returns
Drawable The top compound drawable or null

getContentDescription

public CharSequence getContentDescription (Context context, 
                int year, 
                int month, 
                int day, 
                boolean valid, 
                boolean selected, 
                CharSequence originalContentDescription)

Override this method to return the day view's content description.

Parameters
context Context: The context of the day view

year int: The year number corresponding to the day view (see ERROR(/java.util.Calendar.YEAR))

month int: The month number (0-11) corresponding to the day view (see ERROR(/java.util.Calendar.MONTH))

day int: The day of month number corresponding to the day view (see ERROR(/java.util.Calendar.DAY_OF_MONTH))

valid boolean: Boolean for whether the day view is in a valid state (if not valid, the day view will likely look and behave disabled)

selected boolean: Boolean for whether the day view is in a selected state (if selected, the day view will likely have a filled color background)

originalContentDescription CharSequence: The original day view's content description

Returns
CharSequence The content description

getTextColor

public ColorStateList getTextColor (Context context, 
                int year, 
                int month, 
                int day, 
                boolean valid, 
                boolean selected)

Override this method to return a custom color to be applied to the text of the day view corresponding to the provided date.

Parameters
context Context: The context of the day view

year int: The year number corresponding to the day view (see ERROR(/java.util.Calendar.YEAR))

month int: The month number (0-11) corresponding to the day view (see ERROR(/java.util.Calendar.MONTH))

day int: The day of month number corresponding to the day view (see ERROR(/java.util.Calendar.DAY_OF_MONTH))

valid boolean: Boolean for whether the day view is in a valid state (if not valid, the day view will likely look and behave disabled)

selected boolean: Boolean for whether the day view is in a selected state (if selected, the day view will likely have a filled color background)

Returns
ColorStateList The text color ColorStateList or null

initialize

public void initialize (Context context)

Optionally override this method to do any initializing for your DayViewDecorator instance.

This method will be called whenever the date picker view is created, which can be important if, e.g., your decorator's compound drawables are dependent on configurations such as screen orientation.

Parameters
context Context