java Android 日历视图更改文本颜色
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/37301231/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Android Calendar View change text color
提问by Okke Trommelen
I have a CalendarView
in my app. But I would like to have the background of the CalendarView
black and the text inside the CalendarView
white. But in xml there is no TextColor=
in the CalendarView
. So how can I change the text of the CalendarView
?
CalendarView
我的应用程序中有一个。但我想要CalendarView
黑色的背景和CalendarView
白色的文字。但在XML中是没有TextColor=
的CalendarView
。那么如何更改 的文本CalendarView
呢?
I have tried every solution on StackOverflow and the internet so far. I've managed to change the color of the days in the CalendarView but not the month and year.
到目前为止,我已经尝试了 StackOverflow 和互联网上的所有解决方案。我设法更改了 CalendarView 中日期的颜色,但没有更改月份和年份。
I've tried both methods in this post: Set the text color of calendar view month name
我在这篇文章中尝试了两种方法:设置日历视图月份名称的文本颜色
And I've tried this method: Change CalendarView style
我已经尝试过这种方法: 更改 CalendarView 样式
And some other I found on the internet but nothing was succesfull.
还有一些我在互联网上找到的,但没有成功。
回答by Md Imran Choudhury
Set style in your CalendarView
在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" />
Inside Style.xml
在 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>
回答by jafarbtech
android:theme="@style/testTheme"
Use this theme or a custom theme which has parent as this theme.
使用此主题或以父主题为主题的自定义主题。
To make it white
让它变白
To Choose other than white change the color use the following
要选择白色以外的颜色更改颜色使用以下
android:textColorPrimary="@color/yourColor"
or other text colors use the following
或其他文字颜色使用以下
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"