Remove Title from DatePickerDialog

时光毁灭记忆、已成空白 提交于 2019-11-27 03:22:33

问题


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:

datePickerDialog = new DatePickerDialog(ProfileActivity.this, this, year, month, day);
datePickerDialog.getDatePicker().updateDate(year, month - 1, day);
datePickerDialog.show();

回答1:


datePickerDialog.setTitle("");



回答2:


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.




回答3:


More appropriate so that it even supports holo versions

    datePickerDialog.setCustomTitle(null);



回答4:


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




回答5:


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);


来源:https://stackoverflow.com/questions/33486643/remove-title-from-datepickerdialog

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!