I use CalendarView in my project and I need to make a special design for it. I can change colours of all things in CalendarView but only not colour of month on the top of calendar. I tried all attributes in xml. How I can change colour of month incription and arrows?
<CalendarView
android:id="@+id/calendarID"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="Heh"
android:maxDate="31/12/2018"
android:minDate="09/01/2012"
android:showWeekNumber="false"
android:focusedMonthDateColor="@android:style/TextAppearance.Small"
android:background="#004366"
android:unfocusedMonthDateColor="@android:style/TextAppearance.Small"
android:dateTextAppearance="@android:style/TextAppearance.Small"
android:weekDayTextAppearance="@android:style/TextAppearance.Small"
android:weekSeparatorLineColor="@android:style/TextAppearance.Small"
android:selectedWeekBackgroundColor="@android:style/TextAppearance.Small"
/>
LayoutInflater inflater = (LayoutInflater)getApplicationContext().getSystemService
(Context.LAYOUT_INFLATER_SERVICE);
LinearLayout ll= (LinearLayout)inflater.inflate(R.layout.calendar_moi, null, false);
CalendarView cv = (CalendarView) ll.getChildAt(0);
Long maxData = System.currentTimeMillis();
cv.setMaxDate(maxData);
cv.setOnDateChangeListener(new CalendarView.OnDateChangeListener() {
@Override
public void onSelectedDayChange(CalendarView view, int year, int month,
int dayOfMonth) {
}
});
new AlertDialog.Builder(ItemClassActivity.this)
.setTitle("")
.setMessage("")
.setView(ll)
.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
}
}).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
}
}
).show();
Having defined following in styles.xml
:
<style name="CustomCalendarMonth" parent="AppTheme">
<item name="android:textColorPrimary">@color/orange</item>
</style>
<style name="CustomCalendarDay" parent="TextAppearance.MaterialComponents.Caption">
<item name="android:textColor">@color/green</item>
</style>
<style name="CustomCalendarWeek" parent="TextAppearance.MaterialComponents.Caption">
<item name="android:textColor">@color/purple</item>
</style>
Then in xml:
<CalendarView
android:theme="@style/CustomCalendarMonth"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:dateTextAppearance="@style/CustomCalendarDay"
android:weekDayTextAppearance="@style/CustomCalendarWeek" />
Here will be the output:
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