我们将如何改变整体的背景颜色" CalendarView"在android?

时间:2016-02-09 05:39:00

标签: android calendarview

我对Android很新,我想改变" CalendarView"的背景​​颜色。以编程方式我访问了很多表格,但我没有收到任何特别的答案。

1 个答案:

答案 0 :(得分:0)

您可以更改“日历样式”视图:

<style name="Widget">
    <item name="android:textAppearance">?android:attr/textAppearance</item>
</style>

<style name="Widget.CalendarView">
    <item name="cv_showWeekNumber">true</item>
    <item name="cv_firstDayOfWeek">1</item>
    <item name="cv_minDate">01/01/1900</item>
    <item name="cv_maxDate">12/31/2100</item>
    <item name="cv_shownWeekCount">6</item>
    <item name="cv_selectedWeekBackgroundColor">#330099FF</item>
    <item name="cv_focusedMonthDateColor">#FFFFFFFF</item>
    <item name="cv_unfocusedMonthDateColor">#66FFFFFF</item>
    <item name="cv_weekNumberColor">#33FFFFFF</item>
    <item name="cv_weekSeparatorLineColor">#19FFFFFF</item>
    <item name="cv_selectedDateVerticalBar">@drawable/day_picker_week_view_dayline_holo</item>
    <item name="cv_weekDayTextAppearance">@style/TextAppearance.Small.CalendarViewWeekDayView</item>
    <item name="cv_dateTextAppearance">?android:attr/textAppearanceSmall</item>
</style>

<style name="Widget.Holo.CalendarView" parent="Widget.CalendarView">
    <item name="cv_selectedWeekBackgroundColor">#330099FF</item>
    <item name="cv_focusedMonthDateColor">#FFFFFFFF</item>
    <item name="cv_unfocusedMonthDateColor">#66FFFFFF</item>
    <item name="cv_weekNumberColor">#33FFFFFF</item>
    <item name="cv_weekSeparatorLineColor">#19FFFFFF</item>
    <item name="cv_selectedDateVerticalBar">@drawable/day_picker_week_view_dayline_holo</item>
    <item name="cv_weekDayTextAppearance">@style/TextAppearance.Holo.CalendarViewWeekDayView</item>
    <item name="cv_dividerHorizontal">@drawable/list_divider_holo_dark</item>
</style>

<style name="Widget.Holo.Light.CalendarView" parent="Widget.CalendarView">
    <item name="cv_selectedWeekBackgroundColor">#330066ff</item>
    <item name="cv_focusedMonthDateColor">#FF000000</item>
    <item name="cv_unfocusedMonthDateColor">#7F08002B</item>
    <item name="cv_weekNumberColor">#7F080021</item>
    <item name="cv_weekSeparatorLineColor">#7F08002A</item>
    <item name="cv_weekDayTextAppearance">@style/TextAppearance.Holo.Light.CalendarViewWeekDayView</item>
    <item name="cv_dividerHorizontal">@drawable/list_divider_holo_light</item>
</style>

<style name="TextAppearance.Small.CalendarViewWeekDayView" parent="@android:style/TextAppearance.Small">
    <item name="android:textStyle">bold</item>
</style>

<style name="TextAppearance.Holo.CalendarViewWeekDayView" parent="TextAppearance.Small.CalendarViewWeekDayView">
    <item name="android:textColor">#505050</item>
</style>

<style name="TextAppearance.Holo.Light.CalendarViewWeekDayView" parent="TextAppearance.Small.CalendarViewWeekDayView">
</style>

您可以在日历视图XML中设置这些样式: