Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DatePickerDialog displays with two borders

I have a question about DatePickerDialog displaying.

I want to create date picker dialog with "HoloDialog" theme like this:

DatePickerDialog dpd = new DatePickerDialog(this, android.R.style.Theme_Holo_Dialog, reservationDate, 2014, 1, 1);

Then I will see this result: DatePickerDialog with Holo_Dealog

As you can see, dialog is displayed with "two borders" around.

I want to create the same dialog as displayed here, but with one border around. Is it possible?

like image 216
Ivan B Avatar asked Aug 08 '14 13:08

Ivan B


1 Answers

Assuming I understand your question correctly, I think I found a way. Here, we anonymously subclass DatePickerDialog to override onCreate() and set a transparent background for the window.

DatePickerDialog dpd = new DatePickerDialog(this, android.R.style.Theme_Holo_Dialog,
                                            reservationDate, 2014, 1, 1) {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    }
};

You could also do this with a custom theme instead. For example:

<style name="HoloDialog" parent="@android:style/Theme.Holo.Dialog">
    <item name="android:windowBackground">@android:color/transparent</item>
</style>

Then pass that in the DatePickerDialog's constructor:

DatePickerDialog dpd = new DatePickerDialog(this, R.style.HoloDialog,
                                            reservationDate, 2014, 1, 1);
like image 137
Mike M. Avatar answered Nov 02 '22 10:11

Mike M.