Remove Title from DatePickerDialog

前端 未结 6 1317
误落风尘
误落风尘 2020-12-10 02:57

For some reason, I have two titles in my DatePickerDialog.

How can I get rid of the white title at the top? This is the code I use to create the Dialog:

相关标签:
6条回答
  • 2020-12-10 03:08

    AlertDialog have setCustomHeader method, using it and set a custom view with zero width, zero height. It will work

    LinearLayout linearLayout = new LinearLayout(getApplicationContext());
    timePickerDialog.setCustomTitle(linearLayout);
    
    0 讨论(0)
  • 2020-12-10 03:12

    Use this to also hide the title background

    datePickerDialog.setTitle(null);
    
    0 讨论(0)
  • 2020-12-10 03:15
    datePickerDialog = new DatePickerDialog(ProfileActivity.this, this, year, month, day);
    datePickerDialog.getDatePicker().setMinDate(System.currentTimeMillis());
    datePickerDialog.setTitle("");
    datePickerDialog.show();
    

    your should add datePickerDialog.getDatePicker().setMinDate(System.currentTimeMillis()); and then add datePickerDialog.setTitle("");

    this type of sequence to remove top white background header

    0 讨论(0)
  • 2020-12-10 03:17
    datePickerDialog.setTitle("");
    
    0 讨论(0)
  • 2020-12-10 03:23

    More appropriate so that it even supports holo versions

        datePickerDialog.setCustomTitle(null);
    
    0 讨论(0)
  • 2020-12-10 03:26

    I found that for myself: datePickerDialog.getDatePicker().setMaxDate(c.getTimeInMillis());

    and probably for you: datePickerDialog.getDatePicker().updateDate(year, month - 1, day);

    is the culprit. If you leave that line out, you won't have a title.

    I'm looking into setting a specific theme tosolve the issue.

    -- UPDATE --

    Make sure you call .setTitle(""); AFTER you call .getDatePicker().x(). Otherwise it will not work.

    0 讨论(0)
提交回复
热议问题