diff --git a/lib/java/com/google/android/material/datepicker/MaterialCalendar.java b/lib/java/com/google/android/material/datepicker/MaterialCalendar.java index 2080d96b609..4e5adbdf763 100644 --- a/lib/java/com/google/android/material/datepicker/MaterialCalendar.java +++ b/lib/java/com/google/android/material/datepicker/MaterialCalendar.java @@ -91,6 +91,7 @@ enum CalendarSelector { private View monthNext; private View yearFrame; private View dayFrame; + private MaterialButton toggle; @NonNull public static MaterialCalendar newInstance( @@ -234,7 +235,8 @@ public void onDayClick(long day) { yearSelector.addItemDecoration(createItemDecoration()); } - if (root.findViewById(R.id.month_navigation_fragment_toggle) != null) { + toggle = root.findViewById(R.id.month_navigation_fragment_toggle); + if (toggle != null) { addActionsToMonthNavigation(root, monthsPagerAdapter); } @@ -373,6 +375,7 @@ static int getDayHeight(@NonNull Context context) { void setSelector(CalendarSelector selector) { this.calendarSelector = selector; if (selector == CalendarSelector.YEAR) { + toggle.setIconResource(R.drawable.material_ic_menu_arrow_up_black_24dp); yearSelector .getLayoutManager() .scrollToPosition( @@ -382,6 +385,7 @@ void setSelector(CalendarSelector selector) { monthPrev.setVisibility(View.GONE); monthNext.setVisibility(View.GONE); } else if (selector == CalendarSelector.DAY) { + toggle.setIconResource(R.drawable.material_ic_menu_arrow_down_black_24dp); yearFrame.setVisibility(View.GONE); dayFrame.setVisibility(View.VISIBLE); monthPrev.setVisibility(View.VISIBLE);