GithubHelp home page GithubHelp logo

stacktipslab / custom-calendar-view Goto Github PK

View Code? Open in Web Editor NEW
122.0 8.0 77.0 649 KB

The CustomCalendarView provides an easy and customizable calendar to create a Calendar. It dispaly the days of a month in a grid layout and allows to navigate between months

Home Page: https://stacktips.com/articles/custom-calendar-view-library-in-android

License: Apache License 2.0

Java 100.00%
custom-calendar snippets android android-calendar android-library calendar-view hacktoberfest hacktoberfest-accepted hacktoberfest2023

custom-calendar-view's Introduction

Custom-Calendar-View

To use the CustomCalendarView in your application, you first need to add the library to your application. You can do this either from Gradle, or Maven or by directly downloading the source code from GitHub.

If you enjoy this library, don’t forget to follow me on Twitter @asknilan or visit my stacktips.com.

Alt text

Features

Currently, it supports the following features:

  • Next and previous month's navigation
  • Allow various customization including background color for day, week, and title
  • Set custom typeface using setCustomTypeFace() method.
  • Show hide next previous month's overflow days
  • Set custom day options for the start day of the week. By default, it is set to Calendar.SUNDAY
  • Unlimited customizations for a day of the month using custom Decorators.
  • Allow you to handle events when the user changes month and day selection.

Gradle

Add it to your root build.gradle at the end of repositories:

 dependencyResolutionManagement {
  repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
  repositories {
   mavenCentral()
   maven { url 'https://jitpack.io' }
  }
 }

Step 2: Add the dependency

 dependencies {
         implementation 'com.github.StackTipsLab:custom-calendar-view:1.2.0'
 }

Maven

<repositories>
  <repository>
      <id>jitpack.io</id>
      <url>https://jitpack.io</url>
  </repository>
 </repositories>

Step 2 Add the dependency in the form

 <dependency>
     <groupId>com.github.StackTipsLab</groupId>
     <artifactId>custom-calendar-view</artifactId>
     <version>1.2.0</version>
 </dependency>

Using CustomCalendarView Library

The GitHub project source includes a sample application, that is used for demonstrating the various features currently supported by this library. Once the library is added to your project, you can include the CustomCalendarView into your activity/fragment layout using the following code snippets.

<com.stacktips.view.CustomCalendarView 
    android:id="@+id/calendar_view"
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"
    android:background="#ffffff">
</com.stacktips.view.CustomCalendarView>

The above code snippet will show the simple Calendar View with the default design. Now, you can use the following attributes, to customize the appearance of the calendar.

<com.stacktips.view.CustomCalendarView 
        android:id="@+id/calendar_view"
        android:layout_width="match_parent" 
        android:layout_height="wrap_content"
        android:background="@color/off_white" 
        app:calendarBackgroundColor="@color/off_white"
        app:calendarTitleTextColor="@color/black" 
        app:currentDayOfMonthColor="@color/blue"
        app:dayOfMonthTextColor="@color/black" 
        app:dayOfWeekTextColor="@color/black"
        app:disabledDayBackgroundColor="@color/off_white" 
        app:disabledDayTextColor="@color/grey"
        app:nextMonthNavigationIcon="@drawable/button_next_month_selector"
        app:previousMonthNavigationIcon="@drawable/button_previous_month_selector"
        app:selectedDayBackgroundColor="@color/blue" 
        app:titleLayoutBackgroundColor="@color/white"
        app:weekLayoutBackgroundColor="@color/white">
</com.stacktips.view.CustomCalendarView>

Let us now initialize the calendar view to control the various other appearances and behavior of calendar using the following methods.

//Initialize CustomCalendarView from layout
calendarView=(CustomCalendarView)findViewById(R.id.calendar_view);

//Initialize calendar with date
Calendar currentCalendar=Calendar.getInstance(Locale.getDefault());

//Show Monday as the first date of the week
calendarView.setFirstDayOfWeek(Calendar.MONDAY);

//Show/hide overflow days of a month
calendarView.setShowOverflowDate(false);

//call refreshCalendar to update calendar the view
calendarView.refreshCalendar(currentCalendar);

//Handling custom calendar events
calendarView.setCalendarListener(new CalendarListener(){
        @Override
        public void onDateSelected(Date date){
                SimpleDateFormat df=new SimpleDateFormat("dd-MM-yyyy");
                Toast.makeText(MainActivity.this,df.format(date),Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onMonthChanged(Date date){
                SimpleDateFormat df=new SimpleDateFormat("MM-yyyy");
                Toast.makeText(MainActivity.this,df.format(date),Toast.LENGTH_SHORT).show();
        }
});

Using Custom TypeFace

//Setting custom font
final Typeface typeface=Typeface.createFromAsset(getAssets(),"fonts/Arch_Rival_Bold.ttf");
if(null!=typeface){
    calendarView.setCustomTypeface(typeface);
    calendarView.refreshCalendar(currentCalendar);
}

Custom Calendar View Library in Android Custom Font

Using Day Decorators

//adding calendar day decorators
List decorators=new ArrayList<>();
        decorators.add(new ColorDecorator());
        calendarView.setDecorators(decorators);
        calendarView.refreshCalendar(currentCalendar);
        Custom Calendar View Library in Android Decorator

custom-calendar-view's People

Contributors

cicciogamer890 avatar hamzaawwad avatar hectorfgarcia avatar mitrejcevski avatar nilandev avatar stack143 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

custom-calendar-view's Issues

How to Localize Custom Calendar View?

Your lib is good and have all option that i need in my project.
but My project does not support Locale but your lib show Calendar with Locale language. Eeven i did not use

Calendar currentCalendar = Calendar.getInstance(Locale.getDefault());

Please let me know how can i get Calendar which do not support Locale or disable Locale
Thanks

make date of saturday to red color

hellow, first of all i want to thank you for your awesome Calender view... now what i m trying to implement is make saturday's date text color to red color. thanks in advance

Change Arrow Indicator Image

Hi, your library is awesome.
but is it possible to change the Arrow Indicator Image for next and prev changing month in calendar view ?
I need to custom that for my assignment.
Really appreciate your help.

change style theme to AppCompat

Hi,

is it possible to change the parent theme for this custom view, including a new styled theme, such as
Theme.AppCompat.Light.NoActionBar?

Thanks

Andrea

Calendar view Missing dates - Critical Bug

Calendar view contains the big issue for showing the current month all dates.

For example, if week start from Sunday and month has 31 dates then some how calendar shows 29 dates and next two dates will not show and if the user clicks on next month and now the month is changed and the user can not select 30 and 31 day.Which is a critical bug? How can I fix this issue?

Urgent Solution required for app :(

setting multiple dates

is it possible to set some set of multiple dates as marked in respective months ?
like 01-06-2017 to 10-06-2017 as marked. like that for any months and need to show in UI.

Getting Could not resolve com.github.npanigrahy:Custom-Calendar-View:v1.0. error

Hi @npanigrahy

I need some help for integrating library.
I'm getting following error while compiling android project:
Could not resolve com.github.npanigrahy:Custom-Calendar-View:v1.0.

Following is detailed files:

Top-level build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
        maven { url "https://jitpack.io" }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

project build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion '24.0.1'

    defaultConfig {
        applicationId "com.test.test"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.github.npanigrahy:Custom-Calendar-View:v1.0'

    compile 'com.android.support:appcompat-v7:24.2.1'
    compile 'com.android.support:cardview-v7:24.2.1'
    compile 'com.android.support:design:24.2.1'
    compile 'com.android.support:support-v4:24.2.1'
    compile 'com.android.support:recyclerview-v7:24.+'
}

stack trace
Error:A problem occurred configuring project ':app'.

Could not resolve all dependencies for configuration ':app:_debugApkCopy'.
Could not resolve com.github.npanigrahy:Custom-Calendar-View:v1.0.
Required by:
STYYLE:app:unspecified
> Could not resolve com.github.npanigrahy:Custom-Calendar-View:v1.0.
> Could not get resource 'https://jcenter.bintray.com/com/github/npanigrahy/Custom-Calendar-View/v1.0/Custom-Calendar-View-v1.0.pom'.
> Could not GET 'https://jcenter.bintray.com/com/github/npanigrahy/Custom-Calendar-View/v1.0/Custom-Calendar-View-v1.0.pom'.
> RSA premaster secret error
> Could not resolve com.github.npanigrahy:Custom-Calendar-View:v1.0.
> Could not get resource 'https://repo1.maven.org/maven2/com/github/npanigrahy/Custom-Calendar-View/v1.0/Custom-Calendar-View-v1.0.pom'.
> Could not GET 'https://repo1.maven.org/maven2/com/github/npanigrahy/Custom-Calendar-View/v1.0/Custom-Calendar-View-v1.0.pom'.
> RSA premaster secret error
> Could not resolve com.github.npanigrahy:Custom-Calendar-View:v1.0.
> Could not get resource 'https://jitpack.io/com/github/npanigrahy/Custom-Calendar-View/v1.0/Custom-Calendar-View-v1.0.pom'.
> Could not GET 'https://jitpack.io/com/github/npanigrahy/Custom-Calendar-View/v1.0/Custom-Calendar-View-v1.0.pom'.
> RSA premaster secret error

Thanks in advance.

How to resize calendar?

I want to resize design Calendar in fragment of my app, height weight, height title layout,..: 22dp
And i edited in xml:
android:layout_height="22dp"
in library.
But, i run my app, it's do not resize.
Pls help me.

P/s: Sorry, my english is bad.

How to maintain the color for next next date click

Hi @npanigrahy

Thanks for this library, i need you guidance to do the following,

  1. I set custom color code for holidays(sundays - red color), now i click any one date (in sunday), now the color changed as per selected color,
  2. Now i click next date, then the background color of Sunday is changed as white.(now my predefied red color)

How can i maintain this changes.

Thanks in advance.

Swipe date range selection

Hi,
Your library is awesome.
I only need to know that how can i add swipe to select date range in this.
for example If i tap and hold on 1 and drag to 5 then select dates between 1 to 5

Best Regards

OverFlow row on android 7

When the number of row increased to be 6 rows like December 2017
it never decreased to be 5 again , the overflow row remain existing

how can I selected a date?

If I do
Calendar currentCalendar = Calendar.getInstance(Locale.getDefault()); mCv.refreshCalendar(currentCalendar);

This highlights the actual date, but how can I actually selected the date?
I can't find any method or function to do so.

After day selection, the decorator disappears

After setting DayDecorators on a CustomCalendar, then selecting a day where the decorator was applied, the Decorator disappears.

The day that got selected, then unselected, just gets the normal look for days, and the decorator isn't reloaded.

Is there a special manipulation to do ?

Make all Past date Unselectable.

Hello,

Thanks for the awesome library for CalendarView.
One thing I want to do it, I want to make all past date Unselectable in Calendar.
No past date should be selected. And no one should go to past month as well.
Can you help me achieve this ?

Thanks In Advance.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.