更改CalendarView风格 [英] Change CalendarView style

查看:1731
本文介绍了更改CalendarView风格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想添加一个CalendarView在我的应用程序,它使用了Theme.Light主题。问题是,这个日历天数呈现白色,所以在使用光的主题,你看不到它们。

I'm trying to add a CalendarView in my application, which uses the Theme.Light theme. The problem is, the days numbers of this calendar are rendered in white, so while using a light theme, you can't see them.

现在,我在我的XML布局文件以下code:

Right now, I have the following code in my XML layout file :

<CalendarView
    android:id="@+id/calendar1"
    android:layout_width="500dp"
    android:layout_height="300dp"/>

我试图迫使像这样的日历主题:

I tried to force the calendar theme like this :

<CalendarView
    android:id="@+id/calendar1"
    android:layout_width="500dp"
    android:layout_height="300dp"
    android:theme="@android:style/Theme.Light" />

但它不会改变任何东西。我想我应该做点什么了Android:dateTextAppearance财产,所以我尝试这样的:

But it doesn't change anything. I think I should do something with the android:dateTextAppearance property, so I tried this :

<CalendarView
    android:id="@+id/calendar1"
    android:layout_width="500dp"
    android:layout_height="300dp"
    android:dateTextAppearance="@android:style/TextAppearance.Large.Inverse" />

,但它不既做任何事情。

but it doesn't do anything either.

任何想法?

谢谢!

推荐答案

在我的项目中,我定义的属性机器人:calendarViewStyle。在我的主题

In my project I defined the attribute "android:calendarViewStyle" in my theme.

<style name="Theme.Custom" parent="@android:Theme">
  <item name="android:calendarViewStyle">@style/Widget.CalendarView.Custom</item>
</style>

<style name="Widget.CalendarView.Custom" parent="android:Widget.CalendarView">
    <item name="android:focusedMonthDateColor">@color/cs_textcolor</item>
    <item name="android:weekNumberColor">@color/red</item>
    <item name="android:weekDayTextAppearance">@style/TextAppearance.Medium</item>
    <item name="android:dateTextAppearance">@style/TextAppearance.Medium</item>
</style>

所有样式的可能性是:

All styles possibilities are:

  • @attr楼盘android.R.styleable#CalendarView_showWeekNumber
  • @attr楼盘android.R.styleable#CalendarView_firstDayOfWeek
  • @attr楼盘android.R.styleable#CalendarView_minDate
  • @attr楼盘android.R.styleable#CalendarView_maxDate
  • @attr楼盘android.R.styleable#CalendarView_shownWeekCount
  • @attr楼盘android.R.styleable#CalendarView_selectedWeekBackgroundColor
  • @attr楼盘android.R.styleable#CalendarView_focusedMonthDateColor
  • @attr楼盘android.R.styleable#CalendarView_unfocusedMonthDateColor
  • @attr楼盘android.R.styleable#CalendarView_weekNumberColor
  • @attr楼盘android.R.styleable#CalendarView_weekSeparatorLineColor
  • @attr楼盘android.R.styleable#CalendarView_selectedDateVerticalBar
  • @attr楼盘android.R.styleable#CalendarView_weekDayTextAppearance
  • @attr楼盘android.R.styleable#CalendarView_dateTextAppearance
  • @attr ref android.R.styleable#CalendarView_showWeekNumber
  • @attr ref android.R.styleable#CalendarView_firstDayOfWeek
  • @attr ref android.R.styleable#CalendarView_minDate
  • @attr ref android.R.styleable#CalendarView_maxDate
  • @attr ref android.R.styleable#CalendarView_shownWeekCount
  • @attr ref android.R.styleable#CalendarView_selectedWeekBackgroundColor
  • @attr ref android.R.styleable#CalendarView_focusedMonthDateColor
  • @attr ref android.R.styleable#CalendarView_unfocusedMonthDateColor
  • @attr ref android.R.styleable#CalendarView_weekNumberColor
  • @attr ref android.R.styleable#CalendarView_weekSeparatorLineColor
  • @attr ref android.R.styleable#CalendarView_selectedDateVerticalBar
  • @attr ref android.R.styleable#CalendarView_weekDayTextAppearance
  • @attr ref android.R.styleable#CalendarView_dateTextAppearance

注:如果showWeekNumber不是XML的工作作风,你可以在code与setShowWeekNumber(真)设置

这篇关于更改CalendarView风格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆