I am trying to display a DatePicker
dialog on top of another activity and what is happening is it is somehow inheriting its color.
I'd like it to have a green header and white background,
Here is excerpt from styles
<style name="DatePickerDialog" parent="@android:style/Theme.Holo.Light">
<item name="android:windowFrame">@null</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowIsTranslucent">true</item>
<item name="colorAccent">@color/primary</item>
</style>
And this code is used to pop up the DatePicker
DatePickerDialog datepicker = new DatePickerDialog(this, R.style.DatePickerDialog, new DatePickerDialog.OnDateSetListener() {
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
TextView newdate = (TextView) findViewById(R.id.newdate);
Date date = getDate(year, monthOfYear, dayOfMonth);
DateFormat dateformat = new SimpleDateFormat(getResources().getString(R.string.date_format_full));
newdate.setText(dateformat.format(date));
}
}, newCalendar.get(Calendar.YEAR), newCalendar.get(Calendar.MONTH), newCalendar.get(Calendar.DAY_OF_MONTH));
datepicker.show();
If I specify the white background in the styles,
<item name="android:background">@color/app_background</item>
One last thing I've tried is to use AlertDialog.THEME_DEVICE_DEFAULT_DARK
as the DatePicker
theme
DatePickerDialog datepicker = new DatePickerDialog(this,
AlertDialog.THEME_DEVICE_DEFAULT_DARK, new
DatePickerDialog.OnDateSetListener()
Here is the style of the activity I am opening the dialog from
<style name="UserDialog" parent="android:style/Theme.Dialog">
<item name="android:windowFrame">@null</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:background">@color/primary</item>
<item name="android:textColor">@color/dialog_text</item>
<item name="colorPrimary">@color/app_background</item>
<item name="android:windowTitleStyle">@style/NewDialogTitle</item>
</style>
<style name="NewDialogTitle" parent="@android:style/TextAppearance.DialogWindowTitle">
<item name="android:gravity">center_horizontal</item>
</style>
And the colors I am using
<color name="primary">#4CAF50</color>
<color name="app_background">#FFFFFF</color>
Does anyone know how to get it done? I'd appreciate any guidance. I've tried to follow this answer, but had no luck