问题
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"/>
回答1:
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);
回答2:
//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);
来源:https://stackoverflow.com/questions/33810905/android-calendarview-show-only-one-month-calendar-at-a-time