Reputation: 312
How can I hide the header on the screenshot below?
Upvotes: 11
Views: 8960
Reputation: 1911
ou need to get a reference to the LinearLayout of the DatePicker itself and then .getChildAt(0)
and hide it.
Dialog dialog = new Dialog(context);
dialog.setContentView(R.id.datetime_dialog);
DatePicker datePicker = dialog.findViewById(R.id.dialogDatePicker);
LinearLayout datePickerHeader = (LinearLayout) datePicker.getChildAt(0);
datePickerHeader.setVisibility(View.GONE);
Upvotes: 0
Reputation: 447
Just use calendar view:
<CalendarView
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
Upvotes: 1
Reputation: 5298
In order to display DatePicker as calendar view, without a header, you can switch to spinner mode and hide the spinner, i.e.:
<DatePicker
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:datePickerMode="spinner"
android:spinnersShown="false" />
Upvotes: 6
Reputation: 291
Use a CalendarView instead. Looks the same as a DatePicker, just does not have a header.
Upvotes: 22
Reputation: 556
You could not do much about it, what you can do is forced to be a spinner
<DatePicker
...
android:datePickerMode="spinner" />
Or just create your own custom datePicker http://www.mysamplecode.com/2011/10/android-datepickerdialog.html
Upvotes: 1