如何删除DatePickerDialog背景

时间:2016-10-25 10:28:32

标签: java android datepicker datepickerdialog

我想删除DatePickerDialog

中的额外背景

enter image description here

这是我的代码

DatePickerDialog dpd = new DatePickerDialog(RegisterActivity.this, android.R.style.Theme_Holo_Dialog, date,
                        myCalendar.get(Calendar.YEAR), myCalendar.get(Calendar.MONTH),
                        myCalendar.get(Calendar.DAY_OF_MONTH));

1 个答案:

答案 0 :(得分:1)

您可以像这样覆盖对话框主题:

<style name="TransparentDatePickerDialogTheme" parent="AlertDialog.AppCompat">
    <item name="android:windowBackground">@android:color/transparent</item>
</style>

然后应用这样的主题

DatePickerDialog dpd = new DatePickerDialog(RegisterActivity.this, R.style.TransparentDatePickerDialogTheme, date,
                    myCalendar.get(Calendar.YEAR), myCalendar.get(Calendar.MONTH),
                    myCalendar.get(Calendar.DAY_OF_MONTH));