项目作者: naz013

项目描述 :
Powerful calendar widget for Android
高级语言: Java
项目地址: git://github.com/naz013/awesome-calendar-android.git
创建时间: 2017-08-05T16:55:21Z
项目社区:https://github.com/naz013/awesome-calendar-android

开源协议:MIT License

下载


awesome-calendar-android

Powerful calendar widget for android. Fully written on canvas.
Main idea: write light-weight widget without using additional Android widgets (ViewPager, RecyclerView, TextView, etc.).

Screenshot

Installation

Download latest version with Gradle:

  1. repositories {
  2. maven { url 'https://jitpack.io' }
  3. }
  4. dependencies {
  5. compile 'com.github.naz013:awesome-calendar-android:1.0.2'
  6. }

Usage

Via XML

  1. <com.github.naz013.awcalendar.AwesomeCalendarView
  2. android:id="@+id/calendar_view"
  3. android:layout_width="match_parent"
  4. android:layout_height="wrap_content"
  5. app:ac_day_bg_color="@color/colorPrimary"
  6. app:ac_day_border_color="#ffffff"
  7. app:ac_day_current_text_color="#ff0000"
  8. app:ac_day_text_color="#ffffff"
  9. app:ac_day_unselected_text_color="#40ffffff"
  10. app:ac_event_color="#acacac"
  11. app:ac_highlight_out_of_bounds_days="true"
  12. app:ac_show_weekday_mark="true"
  13. app:ac_start_day_of_week="sunday"
  14. app:ac_type="both"
  15. app:ac_weekday_mark_text_color="#77ff55"
  16. app:ac_weekday_titles="@array/weekday_titles" ></com.github.naz013.awcalendar.AwesomeCalendarView>

Also you can customize view in code:

Border color (ac_day_border_color):

  1. calendarView.setBorderColor(@ColorInt int color)

Background color (ac_day_bg_color):

  1. calendarView.setBackgroundColor(@ColorInt int color)

Day title text color (ac_day_text_color):

  1. calendarView.setTextColor(@ColorInt int color)

Current day title text color (ac_day_current_text_color):

  1. calendarView.setCurrentTextColor(@ColorInt int color)

Text color for days from another month (ac_day_unselected_text_color):

  1. calendarView.setOutTextColor(@ColorInt int color)

To enable different text color for another month use (ac_highlight_out_of_bounds_days):

  1. calendarView.setHighlightOut(boolean highlightOut)

Event mark color (ac_event_color):

  1. calendarView.setEventColor(@ColorInt int color)

Set start day of week (ac_start_day_of_week):

  1. calendarView.setStartDayOfWeek(@IntRange(from = 1, to = 7) int startDayOfWeek)

To enable weekday mark in day cell (ac_show_weekday_mark):

  1. calendarView.setShowWeekdayMark(boolean showWeekdayMark)

Weekday mark text color (ac_weekday_mark_text_color):

  1. calendarView.setWeekdayMarkColor(@ColorInt int color)

Set weekday mark title text (ac_weekday_titles), array or list of strings (must have 7 items):

  1. calendarView.setWeekdayTitles(List<String> weekdayTitles)
  2. calendarView.setWeekdayTitles(String[] weekdayTitles)

Set type of view (ac_type), only via XML:

  • expanded - shows full month;
  • collapsed - shows only one week row;
  • both - shows expanded and collapsed states, depends on user interaction;

When you finish setting parameters in code call:

  1. calendarView.update();

To set events mark to each day cell use (Each Event object has own color parameter):

  1. calendarView.setEvents(List<Event> events)

Also you can set listener for color picker:

  1. calendarView.setOnDateClickListener(new AwesomeCalendarView.OnDateClickListener() {
  2. @Override
  3. public void onDateClicked(DateTime dateTime) {
  4. Log.d(TAG, "onDateClicked: " + dateTime);
  5. }
  6. });
  7. calendarView.setOnCurrentMonthListener(new AwesomeCalendarView.OnCurrentMonthListener() {
  8. @Override
  9. public void onMonthSelected(int year, int month) {
  10. Log.d(TAG, "onMonthSelected: " + year + "-" + month);
  11. }
  12. });
  13. calendarView.setOnDateLongClickListener(new AwesomeCalendarView.OnDateLongClickListener() {
  14. @Override
  15. public void onDateLongClicked(DateTime dateTime) {
  16. Log.d(TAG, "onDateLongClicked: " + dateTime);
  17. }
  18. });

Inspiration

Caldroid - https://github.com/roomorama/Caldroid

Contribution

Library is in development, so feel free to contribute to this project.

License

  1. MIT License
  2. Copyright (c) 2017 Nazar Suhovich
  3. Permission is hereby granted, free of charge, to any person obtaining a copy
  4. of this software and associated documentation files (the "Software"), to deal
  5. in the Software without restriction, including without limitation the rights
  6. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7. copies of the Software, and to permit persons to whom the Software is
  8. furnished to do so, subject to the following conditions:
  9. The above copyright notice and this permission notice shall be included in all
  10. copies or substantial portions of the Software.
  11. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  12. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  13. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  14. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  15. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  16. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  17. SOFTWARE.