I have a Xamarin.Android project targeting API 25 and having API 19 as the minimum SDK, in one of the activities when a button is touched the following DatePickerDialog appears:
As you can see, I defined a custom drawable with rounded corner and used it in the DatePickerDialog. The issue is that I can't get rid of the default background that has a shadowed border when running my application on an Android 4.4.4 device(API 19).
On Android N device (API 25) everything seem to work properly, here is a screenshot:
I would like to know how to remove the default background in Android 4.4.4 devices, is there any useful xml style attribute? Or maybe a programmatic solution? I can't find any resource discussing this issue.
Details
DatePickerFragment implementation that I am using:
public class DatePickerFragment : Android.Support.V4.App.DialogFragment,
Android.App.DatePickerDialog.IOnDateSetListener
{
public static readonly string TAG = "X:" + typeof(DatePickerFragment).Name.ToUpper();
Action<DateTime> _dateSelectedHandler = delegate { };
public static DatePickerFragment NewInstance(Action<DateTime> onDateSelected)
{
DatePickerFragment frag = new DatePickerFragment();
frag._dateSelectedHandler = onDateSelected;
return frag;
}
public override Dialog OnCreateDialog(Bundle savedInstanceState)
{
DateTime currently = DateTime.Now;
DatePickerDialog dialog = new DatePickerDialog(Activity,
Resource.Style.MyDialogTheme,
this,
currently.Year,
currently.Month,
currently.Day);
dialog.SetTitle("");
return dialog;
}
public void OnDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth)
{
DateTime selectedDate = new DateTime(year, monthOfYear + 1, dayOfMonth);
_dateSelectedHandler(selectedDate);
}
}
Style applied to the DatePickerDialog
<style name="MyDialogTheme" parent="Theme.AppCompat.Light.Dialog">
<item name="android:windowFrame">@null</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowBackground">@color/transparent</item>
<item name="android:windowFrame">@color/transparent</item>
<item name="android:colorBackgroundCacheHint">@null</item>
<item name="android:background">@drawable/dialog_background</item>
<item name="android:datePickerStyle">@style/MyDatePicker</item>
<item name="android:backgroundDimEnabled">true</item>
</style>
dialog_background drawable
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<stroke android:width="3dp"
android:color="@color/white" />
<corners android:radius="10dp" />
<solid android:color="@color/white" />
</shape>
MyDatePicker style definition
<style name="MyDatePicker" parent="android:Widget.Material.DatePicker">
<item name="android:datePickerMode">spinner</item>
</style>

