Android. CalendarView...show only one month calendar at a time

Anuj Jindal picture Anuj Jindal · Nov 19, 2015 · Viewed 7.5k times · Source

i am using CalendarView in which i want to view only one month calendar at a time and view next month on scroll but CalendarView shows all the month at a time. below is my code.

<CalendarView
    android:id="@+id/calendView"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_below="@+id/header"
    android:layout_marginTop="60dp"
    android:shownWeekCount="5"/>

Answer

Viral Parmar picture Viral Parmar · Jan 6, 2016

to be frank I didn't find any specific method to do the same.. But you can do it other way round by setting the layout Height to roughly 200dp to 300dp.

<CalendarView
    android:layout_width="match_parent"
    android:layout_height="250dp"
    android:id="@+id/calendarView"
    android:layout_gravity="right"
    />

and if you want to limit your calendar to present date here is the code

CalendarView calendarview;
calendarView = (CalendarView)findViewById(R.id.calendarView);
 long a = calendarView.getDate();
    calendarView.setMaxDate(a);