9

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?

Chris
  • 3,329
  • 1
  • 30
  • 44
Ivan B
  • 394
  • 1
  • 5
  • 18
  • Could you please try to illustrate what you exactly mean with '2 borders'? I don't really see borders. Do you mean that you want to see the spinner for the days also and not only month & year? – Chris Aug 08 '14 at 14:04
  • Look here: http://stackoverflow.com/questions/20148671/android-how-to-change-the-color-of-the-datepicker-divider. This is about how to change color of a dividers. For your case, if you change dividers colors to background, they be not visible. But you want to change only one divider and I don't know how to do this, but hope that idea in the linked answer may help... – krossovochkin Aug 08 '14 at 14:04
  • 1
    @Chris I think he means dividers at the top and bottom of "Feb" and "2014" – krossovochkin Aug 08 '14 at 14:05
  • 1
    @krossovochkin Owh okay, my apologies, i did not understand the question – Chris Aug 08 '14 at 14:07
  • @IvanB, do you mean the window borders? The raised inset look? – Mike M. Aug 08 '14 at 14:32

1 Answers1

21

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);
Mike M.
  • 38,532
  • 8
  • 99
  • 95