Search code examples
androiddatepickerandroid-5.0-lollipop

How to hide Calenderview from DatePicker in API 21


I found that in API 21 android:calendarViewShown="false" is not working, Is there any other method to hide calenderView? or it is a bug?

This is how I declared DatePicker in my code.

        <DatePicker
        android:id="@+id/dp_start_date"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:calendarViewShown="false"
        ></DatePicker>

Solution

  • Try to use android:datePickerMode="spinner". As it's an API 21 attribute, don't forget to make a new layout-v21 folder in your res folder.

    <DatePicker
        android:id="@+id/dp_start_date"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:datePickerMode="spinner"
        android:calendarViewShown="false" />