본문 바로가기
App Programming/Kotlin

[Kotlin] DotSpan (Material CalendarView)

by goatlab 2023. 1. 19.
728x90
반응형
SMALL

DotSpan

 

텍스트 섹션 아래 중앙에 점을 그리는 스팬을 이용하여 달력 날짜에 점 찍기 구현이 가능하다.

 

class main : AppCompatActivity() {
    val binding by lazy { ActivityMainBinding.inflate(layoutInflater)}
    lateinit var calendar: MaterialCalendarView
    private var Today = CalendarDay.today()

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(binding.root)

        val calendar = binding.calendarview
        calendar.setTitleFormatter(
            MonthArrayTitleFormatter(getResources().getTextArray(
            R.array.custom_months))
        );
        calendar.setWeekDayFormatter(ArrayWeekDayFormatter(getResources().getTextArray(R.array.custom_weekdays)));
        calendar.setSelectedDate(CalendarDay.today())

        calendar.addDecorators(
            EventDecorator(Today))
    }
    
    class EventDecorator(dates: Collection<CalendarDay>): DayViewDecorator {

        var dates: HashSet<CalendarDay> = HashSet(dates)

        override fun shouldDecorate(day: CalendarDay?): Boolean {
            return dates.contains(day)
        }

        override fun decorate(view: DayViewFacade?) {
            view?.addSpan(DotSpan(10F, Color.parseColor("#44FF00")))
        }
    }
}

 

https://prolificinteractive.github.io/material-calendarview/com/prolificinteractive/materialcalendarview/spans/DotSpan.html

 

DotSpan

void drawBackground(android.graphics.Canvas canvas, android.graphics.Paint paint, int left, int right, int top, int baseline, int bottom, java.lang.CharSequence charSequence, int start, int end, int lineNum) 

prolificinteractive.github.io

 

728x90
반응형
LIST

'App Programming > Kotlin' 카테고리의 다른 글

[Kotlin] Decorator (Material CalendarView)  (0) 2023.01.19
[Kotlin] Material CalendarView  (0) 2023.01.19
[Kotlin] timePicker  (0) 2023.01.17
[Kotlin] 구글 자동 로그인  (0) 2023.01.15
[Kotlin] 파이어베이스 구글 로그인  (0) 2023.01.15