Is there any way to change the default color of DatePicker
and TimePicker
dialog?
This is the code I tried
<DatePicker
style="@style/date_picker"
android:background="#6495ED"
android:id="@+id/DatePicker"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:layout_marginLeft="5dip"
android:layout_marginRight="5dip" />
<TimePicker
android:id="@+id/TimePicker"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:layout_marginLeft="5dip"
android:layout_marginRight="5dip" />
Below two line only changing the background color, I want to change the default silver color of both date and time picker.
Any help please.
style="@style/date_picker"
android:background="#6495ED"
The best way to change the picker dialog is by adding custom style to it.
<style name="TimePickerTheme" parent="Theme.AppCompat.Light.Dialog">
<item name="colorAccent">@color/color_primary</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
</style>
TimePickerDialog timePicker = new TimePickerDialog(mContext, R.style.TimePickerTheme, fromListener, hour, min, false);
Worked perfectly for me.