-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
日历选择器怎么改成左右翻页? #288
Comments
viewpager 的那种左右切换月份,改动会比较大。将CalendarView中的androidx.recyclerview.widget.RecyclerView改为androidx.viewpager2.widget.ViewPager2可能会小一些,毕竟ViewPager2是基于RecyclerView的。 |
这样写差不多实现了。 |
思路很新奇啊,把竖向的改为横行的 |
但还是不完美,不方便监听当前月份的变化。在改别的日历框架。 |
你再用 RecyclerView bodyView = calendarView.getBodyView();
bodyView.setLayoutManager(new LinearLayoutManager(getContext(), RecyclerView.HORIZONTAL, false));
new PagerSnapHelper().attachToRecyclerView(bodyView); |
不用RecyclerView来重新包装,直接获取CalendarView自带的RecyclerView,应该也就不存在不方便监听当前月份变化的问题了 |
@palorotolo 效果还行吧: CalendarPicker picker = new CalendarPicker(this);
picker.setHeight(CalendarPicker.WRAP_CONTENT);
picker.setRangeDateOnFuture(3);
picker.setFestivalProvider(new MyFestivalProvider());
picker.setOnSingleDatePickListener(new OnSingleDatePickListener() {
@Override
public void onSingleDatePicked(@NonNull Date date) {
singleTimeInMillis = date.getTime();
Toast.makeText(getApplicationContext(), DateFormat.getDateTimeInstance().format(date), Toast.LENGTH_SHORT).show();
}
});
picker.show();
RecyclerView bodyView = picker.getCalendarView().getBodyView();
bodyView.setLayoutManager(new LinearLayoutManager(this, RecyclerView.HORIZONTAL, false));
new PagerSnapHelper().attachToRecyclerView(bodyView); |
类似 viewpager 的那种。按钮左右切换月份。
The text was updated successfully, but these errors were encountered: