如何在Android中更改日期选择器的背景色 [英] How to change background color of datepicker in android
问题描述
我需要在android中更改calendarDatePicker的背景白色。我在SO中尝试了很多链接。但对我没有任何帮助。因此,如果您有任何想法,请与我分享。我知道这是一个重复的问题。但是我的要求是完全不同的。这就是为什么我在这里发布问题。需要将浅灰色更改为我想要的颜色
I need to change the background white color of calendarDatePicker in android. I have tried so many links in SO. but nothing worked for me. So please share with me if you have any ideas. I know this is a duplicate question. but my requirement is completely different. that's why I post question here. need to change the light grey color to what color i want
这是我的日历活动
public void calenderPicker() {
Calendar date = Calendar.getInstance();
CalendarDatePickerDialog calendarDatePickerDialog = CalendarDatePickerDialog.newInstance(Personal.this, date.get(Calendar.YEAR), date.get(Calendar.MONTH),
date.get(Calendar.DAY_OF_MONTH));
calendarDatePickerDialog.show(getFragmentManager(), FRAG_TAG_DATE_PICKER);
}
这是我的onDateset()
@Override
public void onDateSet(CalendarDatePickerDialog calendarDatePickerDialog, int year, int monthOfYear, int dayOfMonth) {
}
推荐答案
用户Raghunandhan准确地指出了必须更改背景颜色的注释。
User Raghunandhan pointed out exactly in comments where you have to change the background color exactly.
他告诉您要查看 github
As he told you to look out this github post.Moreover you can implement this in your project.
在 datetimepicker-library / res / layout / date_picker_selected_date.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@id/day_picker_selected_date_layout"
android:layout_width="@dimen/date_picker_component_width"
android:layout_height="0.0dip"
android:layout_weight="1.0"
android:background="#C689F5" //change the background color for your requirement
android:gravity="center"
android:orientation="vertical">
.........
.........
</LinearLayout>
输出:
这篇关于如何在Android中更改日期选择器的背景色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!