Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/recruit-mp/LightCalendarView
A lightweight monthly calendar view for Android, fully written in Kotlin. Designed to meet the minimum demands for typical calendars.
https://github.com/recruit-mp/LightCalendarView
Last synced: about 1 month ago
JSON representation
A lightweight monthly calendar view for Android, fully written in Kotlin. Designed to meet the minimum demands for typical calendars.
- Host: GitHub
- URL: https://github.com/recruit-mp/LightCalendarView
- Owner: recruit-mp
- License: apache-2.0
- Created: 2016-11-21T04:31:50.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-04-24T05:57:56.000Z (over 7 years ago)
- Last Synced: 2024-08-02T05:15:37.102Z (4 months ago)
- Language: Kotlin
- Homepage:
- Size: 192 KB
- Stars: 444
- Watchers: 20
- Forks: 68
- Open Issues: 22
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
- awesome-kotlin-android - LightCalendarView - 轻量级日历🔥🔥 (开源库 / UI)
README
# Light Calendar View
[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-LightCalendarView-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/4696)
[![Release](https://img.shields.io/github/release/recruit-mp/LightCalendarView.svg?label=maven%20version)](https://github.com/recruit-mp/LightCalendarView)
[![License](https://img.shields.io/hexpm/l/plug.svg)]()A lightweight monthly calendar view for Android, fully written in Kotlin. Designed to meet the minimum demands for typical calendars.
## Requirements
* Target SDK version: 23
* Minimum SDK version: 15## Usage
1) Add these settings to your app-level **build.gradle**.
```groovy
dependencies {
compile 'jp.co.recruit_mp:LightCalendarView:1.0.1'
}
```2) Add `LightCalendarView` into your layouts or view hierarchy.
```xml...
...```
## Customization
### Options
Lightweight Calendar View can be easily customized by setting properties in the layout XML file.
```xml
```The following properties are available:
| property name | type | description |
| -------------------------- | ----------------- | ------------------------------------------------------------------- |
| app:lcv_weekDayTextSize | dimension | The text size of weekdays |
| app:lcv_dayTextSize | dimension | The text size of days |
| app:lcv_textColor | color or resource | The text color of weekdays and days |
| app:lcv_selectionColor | color or resource | The background color of selections |
| app:lcv_accentColor | color or resource | The color of accents |
| app:lcv_firstDayOfWeek | integer | The first day of the week (0 = Sunday, 1 = Monday, ..., 6 = Friday) |The customizations of text colors of selected days or today are done by setting <selector /> color resources to `app:lcv_textColor`, `app:lcv_selectionColor`, or `app:lcv_accentColor` with the following resource files for example.
**NOTE** that in all of the color resources, `android:state_*` are used to distinguish the state of each day view as follows:
| state | description |
| -------------------------- | ----------------------------------------------------------------------------- |
| android:state_active | indicates whether the day view is for today (_true_) or other days (_false_) |
| android:state_selected | indicates whether the day view is selected (_true_) or not (_false_) |`/res/color/calendar_day_text.xml`
```xml
```
`/res/color/calendar_selection.xml`
```xml
```
`/res/color/calendar_accent.xml`
```xml
```
### OnCalendarStateUpdatedListener
Add `OnCalendarStateUpdatedListener` to the calendar view to detect and handle the following events:* `onSelectMonth()`: the user swipes and changes the month
* `onSelectDay()`: the user clicks one day in a month viewSee [the example implementation in MainActivity.kt](sample/src/main/kotlin/jp/co/recruit_mp/android/lightcalendarview/sample/MainActivity.kt) of this listener on github.
### Decorations
Use `MonthView#setAccents(Date, Collection)` or `MonthView#setAccents(Map>)` to add decorations to each day.
Example:
```kotlin
calendarView.setOnStateUpdatedListener(object : LightCalendarView.OnStateUpdatedListener {
override fun onMonthSelected(date: Date, view: MonthView) {
val cal = Calendar.getInstance().apply { time = date }
val monthEvents: Map> = someApi.getMonthEvents(cal[Calendar.YEAR], cal[Calendar.MONTH])
val monthAccents: Map> = monthEvents.mapValues { event -> DotAccent(radius = 10f, color = event.color, key = event) }
view.setAccents(monthAccents)
}
}
```### Coloring Day of The Week
Use `LightCalendarView#setWeekDayFilterColor(weekDay: WeekDay, color: Int?)` and `LightCalendarView#setDayFilterColor(weekDay: WeekDay, color: Int?)` to set the color scheme of day of the week in WeekDayView (e.g. Sunday, Monday, ...) and DayView (e.g. 1, 2, ...) respectively.
```kotlin
// coloring "sunday" (day of the week) in red
calendarView.setWeekDayFilterColor(WeekDay.SUNDAY, Color.RED)// coloring sundays (days) in red
calendarView.setDayFilterColor(WeekDay.SUNDAY, Color.RED)
```Note the library internally uses these color as ColorFilter, meaning it is overlayed on top of the text color set through `LightCalendarView#setTextColor(color: Int)`.
### Further Customizations
See [the Wiki](https://github.com/recruit-mp/LightCalendarView/wiki) for more information and descriptions on futher customizations.
## Contributing
Contributions to this library, including bug-reporting, bug-fixes, and enhancements are always welcomed. Just create an issue, fork us and send a pull request.### License
```
Copyright 2016 RECRUIT MARKETING PARTNERS CO., LTD.Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
```### Maintainers
Light Calendar View is owned and maintained by Recruit Marketing Partners Co., Ltd, and was originally created by* [Masayuki Hayashi](https://github.com/tglovernuppy)
* [Yuki Mima](https://github.com/amyu)