How can I change Android MaterialCalendarView month color?

纵然是瞬间 提交于 2019-12-25 00:26:14

问题


I'm using Xamarin Android MaterialViewCalendar

Month header dissappears on some devices, so I want to set it's color manually.

<com.prolificinteractive.materialcalendarview.MaterialCalendarView
    android:id="@+id/calendarView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@android:color/white"
    app:mcv_showOtherDates="all"
/>

回答1:


How can I change Android MaterialCalendarView month color?

When you use MaterialCalendarView, there are three different text appearances you can set :

  • Header

    mcv_headerTextAppearance or setHeaderTextAppearance()

  • Weekday

    mcv_weekDayTextAppearance or setWeekDayTextAppearance()

  • Date

    mcv_dateTextAppearance or setDateTextAppearance()

The header text appearance is used for the topbar month label. The weekday is for the row of weekday labels, and date is for the individual days.

You could use mcv_headerTextAppearance or setHeaderTextAppearance() to set the MaterialCalendarView month color. For more information, you could read he document.

Usage like this :

materialCalendarView.SetHeaderTextAppearance();

or

app:mcv_headerTextAppearance="@style/CustomTextAppearance"



回答2:


Step 1:

In styles add your own style

<style name="CalendarWidgetHeader">
    <item name="android:textSize">18sp</item>
    <item name="android:textStyle">bold</item>
    <item name="android:textColor">@color/black</item>
</style>

Step 2:

calendarView.setHeaderTextAppearance(R.style.CalendarWidgetHeader);


来源:https://stackoverflow.com/questions/45432524/how-can-i-change-android-materialcalendarview-month-color

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!