Vertical Scroll Calendar

Additional

Language
Java
Version
N/A
Created
Nov 4, 2019
Updated
Mar 3, 2021 (Retired)
Owner
emcthye
Contributor
emcthye
1
Activity
Badge
Generate
Download
Source code

VerticalCalendar

Scroll calendar days infinitely in a vertical column.

Installation

Import with Gradle:

dependencies {
  implementation 'com.emc.thye:VerticalCalendar:1.0.4'
}

Basic Usage

<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);

Date Click Listener

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;
        }
    }
});

Date Watcher

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;
    }
});

Customization

Day Text

  • customFont - .otf/.ttf placed in res/font folder
  • dayTextColor
  • weekDayTextColor
  • selectedDayTextColor

Day Background

  • dayBackground
  • selectedBackground