Reputation: 1719
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"/>
Upvotes: 4
Views: 8749
Reputation: 101
//get month and get how many days in current month
Calendar calendar = Calendar.getInstance();
int daysInMonth = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
cal.setMaxDate(daysInMonth);
Upvotes: 0
Reputation: 112
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);
Upvotes: 0