In android , i am using an default CalendarView. I have set the background to light gray color. But can i change the color of month view of calendar view?
All you need to do then is draw the listed colours on the canvas in the WeekView class method called drawWeekNumbersAndDates() for the specified dates using the existing for loop ( for (; i < nDays; i++) ) and iterate over the Map and change the paint colour for the date text i.e. mMonthNumDrawPaint. setColor().
Change the Google Calendar Default Color on Mobile The steps are the same for the Google Calendar app on both Android and iOS. Tap the menu button on the top left and select Settings near the bottom. Below the calendar you want to change, tap Events. Tap Color at the top and pick a new color.
As you've found out, the TextView is private, and there does not seem to be any methods for accessing it.
Although I wouldn't recommend it, you can accomplish this using the java.lang.reflect
package:
try
{
CalendarView cv = (CalendarView) this.findViewById(R.id.calendarView1);
Class<?> cvClass = cv.getClass();
Field field = cvClass.getDeclaredField("mMonthName");
field.setAccessible(true);
try
{
TextView tv = (TextView) field.get(cv);
tv.setTextColor(Color.RED);
}
catch (IllegalArgumentException e)
{
e.printStackTrace();
}
catch (IllegalAccessException e)
{
e.printStackTrace();
}
}
catch (NoSuchFieldException e)
{
e.printStackTrace();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With