last-Programmer
last-Programmer

Reputation: 1019

Android Datepicker dialog is having transparent background

I am using datepickerdialog in dialogfragement and the spinners are transparent as showing in this imageTransparent Spinners How i can fix this?

Thanks

Upvotes: 2

Views: 2066

Answers (2)

M.U
M.U

Reputation: 49

DatePickerDialog dialog = new DatePickerDialog(context, R.style.DialogTheme,
            new MyDateSetListener(), selectedYear, selectedMonth, selectedDate);
dialog.getWindow().setBackgroundDrawable(getDrawable(R.color.white));

I faced same problem and this did the job done

Upvotes: 0

Kameswari
Kameswari

Reputation: 758

Define a custom dialog theme by setting the back ground color in your styles.xml as below.

<style name="DialogTheme" parent="Theme.AppCompat.Light.Dialog">
    <item name="colorAccent">@color/white</item>
</style>

And apply this theme to the date picker dialog while creating as

DatePickerDialog dialog = new DatePickerDialog(context, R.style.DialogTheme,
                new MyDateSetListener(), selectedYear, selectedMonth, selectedDate);

Hope this helps.

Upvotes: 2

Related Questions