Coder Social home page Coder Social logo

hehonghui / android-week-view Goto Github PK

View Code? Open in Web Editor NEW

This project forked from alamkanak/android-week-view

0.0 2.0 0.0 547 KB

Android Week View is an android library to display calendars (week view or day view) within the app. It supports custom styling.

License: Apache License 2.0

android-week-view's Introduction

Android Week View

Android Week View is an android library to display calendars (week view or day view) within the app. It supports custom styling.

Please note that this project is still under development. I will be happy if you collaborate in this project and help it become even more polished.

Features

  • Week view calendar
  • Day view calendar
  • Custom styling
  • Horizontal and vertical scrolling
  • Infinite horizontal scrolling
  • Live preview of custom styling in xml preview window

Who uses it

Usage

  1. Import the library into your project.
  • Grab via maven

    <dependency>
      <groupId>com.github.alamkanak</groupId>
      <artifactId>android-week-view</artifactId>
      <version>1.1.1</version>
      <type>aar</type>
    </dependency>
  • Grab via gradle

    compile 'com.github.alamkanak:android-week-view:1.1.1'
  1. Add WeekView in your xml layout.

    <com.alamkanak.weekview.WeekView
            android:id="@+id/weekView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:eventTextColor="@android:color/white"
            app:textSize="12sp"
            app:hourHeight="60dp"
            app:headerColumnPadding="8dp"
            app:headerColumnTextColor="#8f000000"
            app:headerRowPadding="12dp"
            app:columnGap="8dp"
            app:noOfVisibleDays="3"
            app:headerRowBackgroundColor="#ffefefef"
            app:dayBackgroundColor="#05000000"
            app:todayBackgroundColor="#1848adff"
            app:headerColumnBackground="#ffffffff"/>
  2. Write the following code in your java file.

    // Get a reference for the week view in the layout.
    mWeekView = (WeekView) findViewById(R.id.weekView);
    
    // Set an action when any event is clicked.
    mWeekView.setOnEventClickListener(mEventClickListener);
    
    // The week view has infinite scrolling horizontally. We have to provide the events of a
    // month every time the month changes on the week view.
    mWeekView.setMonthChangeListener(mMonthChangeListener);
    
    // Set long press listener for events.
    mWeekView.setEventLongPressListener(mEventLongPressListener);
  3. Implement WeekView.MonthChangeListener, WeekView.EventClickListener, WeekView.EventLongPressListener according to your need.

  4. Provide the events for the WeekView in WeekView.MonthChangeListener.onMonthChange() callback. Please remember that the calendar preloads events of three consecutive months to enable lag-free scrolling.

    WeekView.MonthChangeListener mMonthChangeListener = new WeekView.MonthChangeListener() {
        @Override
        public List<WeekViewEvent> onMonthChange(int newYear, int newMonth) {
            // Populate the week view with some events.
            List<WeekViewEvent> events = getEvents(newYear, newMonth);
            return events;
        }
    };

Customization

You can customize the look of the WeekView in xml. Use the following attributes in xml. All these attributes also have getters and setters to enable you to change the style dynamically.

  • columnGap
  • dayBackgroundColor
  • dayNameLength
  • eventPadding
  • eventTextColor
  • eventTextSize
  • firstDayOfWeek
  • headerColumnBackground
  • headerColumnPadding
  • headerColumnTextColor
  • headerRowBackgroundColor
  • headerRowPadding
  • hourHeight
  • hourSeparatorColor
  • hourSeparatorHeight
  • noOfVisibleDays
  • textSize
  • todayBackgroundColor
  • todayHeaderTextColor

Sample

There is also a sample app to get you started.

To do

  • Add event touch feedback selector
  • Show events that expand multiple days properly

Changelog

Version 1.1.1

  • Overlapping event bug fixed

Version 1.1.0

  • Added support for overlapping events

License

Copyright 2014 Raquib-ul-Alam

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 at

   http://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.

android-week-view's People

Contributors

alamkanak avatar

Watchers

Mr.Simple avatar  avatar

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.