Anitha
Anitha

Reputation: 1055

How to change background color of datepicker in android

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

enter image description here

Upvotes: 5

Views: 5695

Answers (1)

Stephen
Stephen

Reputation: 10059

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:

enter image description here

Upvotes: 4

Related Questions