calendarview highlights wrong week

╄→гoц情女王★ 提交于 2019-12-05 18:32:49

I have had the same issue as you, using a Samsung S5 running API 21.

There are two workarounds that I have found, none of them is a good experience for our users :(

  1. Force first day of the week to Sunday

    calendarView.setFirstDayOfTheWeek(Calendar.SUNDAY);
  1. Set a minimum and a maximum date for the calendar (be careful because not all of the dates work here). I was able to make it work properly setting a minimum date 2 months before the current date and maximum date 2 years after the current date. You can play with these values and find a good compromise between the limits and your user experience.

    Calendar calendar = Calendar.getInstance();
    calendar.set(Calendar.MONTH, calendar.get(Calendar.MONTH) - 2);
    calendarView.setMinDate(calendar.getTimeInMillis());
    calendar.set(Calendar.YEAR, calendar.get(Calendar.YEAR) + 2);
    calendarView.setMaxDate(calendar.getTimeInMillis());

Unfortunately, this is the only way I could fix this issue, I hope it is useful for you.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!