Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 391
Anitha Avatar asked Sep 29 '22 12:09

Anitha


1 Answers

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

like image 200
Steve Avatar answered Oct 13 '22 00:10

Steve