2016-05-18 49 views
2

我在我的應用程序中有一個CalendarView。但我想有CalendarView黑色背景和CalendarView白色背景中的文字。但是在xml中CalendarView中沒有TextColor=。那麼如何更改CalendarView的文字?Android日曆查看更改文字顏色

到目前爲止,我已經嘗試了StackOverflow和互聯網上的每個解決方案。我設法更改CalendarView中日期的顏色,但不是月份和年份。

我試圖在這個崗位兩種方法:Set the text color of calendar view month name

而且我試過這個方法: Change CalendarView style

和其他一些我在互聯網上找到,但沒有什麼是succesfull。

+2

請看看這個以前[questioin](http://stackoverflow.com/questions/9412402/change-calendarview-style) –

回答

-1
android:theme="@style/testTheme" 

使用此主題或以父爲主題的自定義主題。

爲了使白

選擇不同於白色變化的顏色使用下面的

android:textColorPrimary="@color/yourColor" 

或其他文本顏色使用其他下面的

android:weekDayTextAppearance="@style/weekDayTextAppearance" 
    android:dateTextAppearance="@style/appTextAppearance" 
    android:unfocusedMonthDateColor="@color/colorLoginBtn" 
    android:selectedWeekBackgroundColor="@color/colorLoginBtn" 
    android:weekSeparatorLineColor="@color/colorLoginBtn" 
    android:focusedMonthDateColor="@color/colorLoginBtn" 
    android:weekNumberColor="@color/colorLoginBtn" 
1

設置樣式您CalendarView

<CalendarView 
    android:id="@+id/calendarView" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_gravity="center" 
    android:theme="@style/CalenderViewCustom" 
    android:dateTextAppearance="@style/CalenderViewDateCustomText" 
    android:weekDayTextAppearance="@style/CalenderViewWeekCustomText" /> 

內Style.xml

<style name="CalenderViewCustom" parent="Theme.AppCompat"> 
     <item name="colorAccent">@color/red</item> 
     <item name="colorPrimary">@color/white</item> 
    </style> 

    <style name="CalenderViewDateCustomText" parent="android:TextAppearance.DeviceDefault.Small"> 
     <item name="android:textColor">@color/white</item> 
     <item name="android:weekNumberColor">@color/red</item> 
    </style> 

    <style name="CalenderViewWeekCustomText" parent="android:TextAppearance.DeviceDefault.Small"> 
     <item name="android:textColor">@color/white</item> 
    </style>