How to change background color of datepicker in android

偶尔善良 提交于 2019-12-23 09:49:00

问题


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

this is my calendar activity

    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);
    }

this is my onDateset()

@Override
    public void onDateSet(CalendarDatePickerDialog calendarDatePickerDialog, int year, int monthOfYear, int dayOfMonth) {
}


回答1:


User Raghunandhan pointed out exactly in comments where you have to change the background color exactly.

As he told you to look out this github post.Moreover you can implement this in your project.

In 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>

Output:



来源:https://stackoverflow.com/questions/29096587/how-to-change-background-color-of-datepicker-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!