我正尝试在使用Theme.Light主题的应用程序中添加一个CalendarView。问题是,这个日历的天数是用白色呈现的,所以当使用轻主题时,你看不到它们。
现在,我的XML布局文件中有以下代码:
<CalendarView
android:id="@+id/calendar1"
android:layout_width="500dp"
android:layout_height="300dp"/>我试着像这样强制日历主题:
<CalendarView
android:id="@+id/calendar1"
android:layout_width="500dp"
android:layout_height="300dp"
android:theme="@android:style/Theme.Light" />但这不会改变任何事。我想我应该对android:dateTextAppe现属性做点什么,所以我尝试了一下:
<CalendarView
android:id="@+id/calendar1"
android:layout_width="500dp"
android:layout_height="300dp"
android:dateTextAppearance="@android:style/TextAppearance.Large.Inverse" />但是它也不能做任何事情。
有什么想法吗?
谢谢!
发布于 2012-03-26 17:07:06
在我的项目中,我在主题中定义了"android:calendarViewStyle“属性。
<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>所有可能的样式是:
ref ref @attr ref android.R.styleable#CalendarView_showWeekNumber
注意:如果showWeekNumber不能作为xml样式使用,您可以在代码中使用setShowWeekNumber(true)进行设置。
发布于 2017-05-11 03:14:35
我也遇到了很多麻烦。虽然不是完美的,我也没有想出如何修改每个方面,但我接近了。这就是我是如何做到的,在项目的styles.xml中我添加了这些样式:
<style name="CalenderViewCustom" parent="Theme.AppCompat">
<item name="colorAccent">@color/white_30</item>
</style>
<style name="CalenderViewDateCustomText" parent="android:TextAppearance.DeviceDefault.Small">
<item name="android:textColor">@color/white</item>
</style>
<style name="CalenderViewWeekCustomText" parent="android:TextAppearance.DeviceDefault.Small">
<item name="android:textColor">@color/white_30</item>
</style>然后,对于CalendarView,我这样引用了这些样式:
<CalendarView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:theme="@style/CalenderViewCustom"
android:dateTextAppearance="@style/CalenderViewDateCustomText"
android:weekDayTextAppearance="@style/CalenderViewWeekCustomText"/>您可以将其他类型的颜色(原色/次色)添加到上面的CalenderViewCustom中。
https://stackoverflow.com/questions/9412402
复制相似问题