Semen Tykhonenko
Semen Tykhonenko

Reputation: 312

How to hide header in CalendarView in DatePicker?

How can I hide the header on the screenshot below?

enter image description here

Upvotes: 11

Views: 8960

Answers (5)

Miguel Tomás
Miguel Tomás

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

Nrohpos
Nrohpos

Reputation: 447

Just use calendar view:

<CalendarView
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"/>

Upvotes: 1

Ramps
Ramps

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

Chris Hare
Chris Hare

Reputation: 291

Use a CalendarView instead. Looks the same as a DatePicker, just does not have a header.

Upvotes: 22

Helmi
Helmi

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

Related Questions