Scroll calendar days infinitely in a vertical column.
dependencies {
implementation 'com.emc.thye:VerticalCalendar:1.0.4'
}
<com.emc.verticalweekcalendar.VerticalWeekCalendar
android:id="@+id/verticalCalendar"
android:layout_width="wrap_content"
android:layout_height="match_parent"
app:customFont="quicksand_bold"
app:selectedBackground="@color/colorSelectedDayBG"/>
VerticalWeekCalendar calendarView = new VerticalWeekCalendar.Builder()
.setView(R.id.verticalCalendar)
.init(this);
private GregorianCalendar selected;
calendarView.setOnDateClickListener(new OnDateClickListener() {
@Override
public void onCalenderDayClicked(int year, int month, int day) {
GregorianCalendar selectedDay = new GregorianCalendar(year, month, day);
if(selected.compareTo(selectedDay) != 0) {
//Not the same day is clicked
selected = selectedDay;
}
}
});
There are two built-in state, SELECTED & DEFAULT that changes the day view's background color. You can also implement your own logic by returning CalendarDay.DEFAULT as the state and use VerticalWeekAdapter.DayViewHolder view as the reference to change the view properties.
calendarView.setDateWatcher(new DateWatcher() {
@Override
public int getStateForDate(int year, int month, int day, VerticalWeekAdapter.DayViewHolder view) {
view.dayView.setBackgroundColor(Color.parseColor("#ff4000"));
return selected.compareTo(new GregorianCalendar(year, month, day)) == 0 ?
CalendarDay.SELECTED : CalendarDay.DEFAULT;
}
});
- customFont - .otf/.ttf placed in res/font folder
- dayTextColor
- weekDayTextColor
- selectedDayTextColor
- dayBackground
- selectedBackground