# DayViewDecorator

[View Source](https://github.com/material-components/material-components-android/blob/1.14.0/lib/java/com/google/android/material/datepicker/DayViewDecorator.java)

*** ** * ** ***


```
public abstract class DayViewDecorator
```

<br />

*** ** * ** ***

A decorator which allows customizing the day of month views within a `https://developer.android.com/reference/com/google/android/material/datepicker/MaterialDatePicker`.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/com/google/android/material/datepicker/DayViewDecorator#DayViewDecorator()()` |

| ### Public methods |
|---|---|
| `ColorStateList` | `https://developer.android.com/reference/com/google/android/material/datepicker/DayViewDecorator#getBackgroundColor(Context,int,int,int,boolean,boolean)( 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` | `https://developer.android.com/reference/com/google/android/material/datepicker/DayViewDecorator#getCompoundDrawableBottom(Context,int,int,int,boolean,boolean)( 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` | `https://developer.android.com/reference/com/google/android/material/datepicker/DayViewDecorator#getCompoundDrawableLeft(Context,int,int,int,boolean,boolean)( 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` | `https://developer.android.com/reference/com/google/android/material/datepicker/DayViewDecorator#getCompoundDrawableRight(Context,int,int,int,boolean,boolean)( 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` | `https://developer.android.com/reference/com/google/android/material/datepicker/DayViewDecorator#getCompoundDrawableTop(Context,int,int,int,boolean,boolean)( 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. |
| `https://developer.android.com/reference/java/lang/CharSequence` | `https://developer.android.com/reference/com/google/android/material/datepicker/DayViewDecorator#getContentDescription(Context,int,int,int,boolean,boolean,java.lang.CharSequence)( Context context, int year, int month, int day, boolean valid, boolean selected, https://developer.android.com/reference/java/lang/CharSequence originalContentDescription )` Override this method to return the day view's content description. |
| `ColorStateList` | `https://developer.android.com/reference/com/google/android/material/datepicker/DayViewDecorator#getTextColor(Context,int,int,int,boolean,boolean)( 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` | `https://developer.android.com/reference/com/google/android/material/datepicker/DayViewDecorator#initialize(Context)(Context context)` Optionally override this method to do any initializing for your `DayViewDecorator` instance. |

## 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 |
| `int year` | The year number corresponding to the day view (see `https://developer.android.com/reference/java/util/Calendar#YEAR()`) |
| `int month` | The month number (0-11) corresponding to the day view (see `https://developer.android.com/reference/java/util/Calendar#MONTH()`) |
| `int day` | The day of month number corresponding to the day view (see `https://developer.android.com/reference/java/util/Calendar#DAY_OF_MONTH()`) |
| `boolean valid` | Boolean for whether the day view is in a valid state (if not valid, the day view will likely look and behave disabled) |
| `boolean selected` | 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 |
| `int year` | The year number corresponding to the day view (see `https://developer.android.com/reference/java/util/Calendar#YEAR()`) |
| `int month` | The month number (0-11) corresponding to the day view (see `https://developer.android.com/reference/java/util/Calendar#MONTH()`) |
| `int day` | The day of month number corresponding to the day view (see `https://developer.android.com/reference/java/util/Calendar#DAY_OF_MONTH()`) |
| `boolean valid` | Boolean for whether the day view is in a valid state (if not valid, the day view will likely look and behave disabled) |
| `boolean selected` | 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 |
| `int year` | The year number corresponding to the day view (see `https://developer.android.com/reference/java/util/Calendar#YEAR()`) |
| `int month` | The month number (0-11) corresponding to the day view (see `https://developer.android.com/reference/java/util/Calendar#MONTH()`) |
| `int day` | The day of month number corresponding to the day view (see `https://developer.android.com/reference/java/util/Calendar#DAY_OF_MONTH()`) |
| `boolean valid` | Boolean for whether the day view is in a valid state (if not valid, the day view will likely look and behave disabled) |
| `boolean selected` | 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 |
| `int year` | The year number corresponding to the day view (see `https://developer.android.com/reference/java/util/Calendar#YEAR()`) |
| `int month` | The month number (0-11) corresponding to the day view (see `https://developer.android.com/reference/java/util/Calendar#MONTH()`) |
| `int day` | The day of month number corresponding to the day view (see `https://developer.android.com/reference/java/util/Calendar#DAY_OF_MONTH()`) |
| `boolean valid` | Boolean for whether the day view is in a valid state (if not valid, the day view will likely look and behave disabled) |
| `boolean selected` | 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 |
| `int year` | The year number corresponding to the day view (see `https://developer.android.com/reference/java/util/Calendar#YEAR()`) |
| `int month` | The month number (0-11) corresponding to the day view (see `https://developer.android.com/reference/java/util/Calendar#MONTH()`) |
| `int day` | The day of month number corresponding to the day view (see `https://developer.android.com/reference/java/util/Calendar#DAY_OF_MONTH()`) |
| `boolean valid` | Boolean for whether the day view is in a valid state (if not valid, the day view will likely look and behave disabled) |
| `boolean selected` | 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 |
| `int year` | The year number corresponding to the day view (see `https://developer.android.com/reference/java/util/Calendar#YEAR()`) |
| `int month` | The month number (0-11) corresponding to the day view (see `https://developer.android.com/reference/java/util/Calendar#MONTH()`) |
| `int day` | The day of month number corresponding to the day view (see `https://developer.android.com/reference/java/util/Calendar#DAY_OF_MONTH()`) |
| `boolean valid` | Boolean for whether the day view is in a valid state (if not valid, the day view will likely look and behave disabled) |
| `boolean selected` | Boolean for whether the day view is in a selected state (if selected, the day view will likely have a filled color background) |
| `https://developer.android.com/reference/java/lang/CharSequence originalContentDescription` | The original day view's content description |

| Returns |
|---|---|
| `https://developer.android.com/reference/java/lang/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 |
| `int year` | The year number corresponding to the day view (see `https://developer.android.com/reference/java/util/Calendar#YEAR()`) |
| `int month` | The month number (0-11) corresponding to the day view (see `https://developer.android.com/reference/java/util/Calendar#MONTH()`) |
| `int day` | The day of month number corresponding to the day view (see `https://developer.android.com/reference/java/util/Calendar#DAY_OF_MONTH()`) |
| `boolean valid` | Boolean for whether the day view is in a valid state (if not valid, the day view will likely look and behave disabled) |
| `boolean selected` | 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.