Open Source project material Calendar View Learning record (i)

Source: Internet
Author: User

Open Source project material Calendar View Learning record

Github:

Https://github.com/prolificinteractive/material-calendarview

README.MD Chinese Translation:

Material Calendar View CalendarView the Android Material design style backwards. The goal is to have material visual and use effects, rather than relying entirely on the implementation of the platform.

Major changes to the 0.8.0 version

This view now responds better to layout parameters. This feature is similar to the adjustviewbounds parameter on ImageView, which causes the view to attempt to occupy as much space as needed, but we are based on the tile size instead of the aspect ratio. The exception is if the Tilesize parameter is set, the other parameters are overwritten and the view is set to that dimension.

How to use

1, add compile ' com.prolificinteractive:material-calendarview:0.8.1 ' to your dependencies.

2. Add Materialcalendarview to your layout or view layer.

3, if required, set a ondatechangedlistener or call Materialcalendarview.getselecteddate ().

Example:

<Com.prolificinteractive.materialcalendarview.MaterialCalendarViewAndroid:id= "@+id/calendarview"Android:layout_width= "Match_parent"Android:layout_height= "Wrap_content"      
Xmlns:app= "Http://schemas.android.com/apk/res-auto"
App:mcv_showotherdates= "Boolean"App:mcv_arrowcolor= "Color"App:mcv_selectioncolor= "Color"app:mcv_headertextappearance= "Style"app:mcv_datetextappearance= "Style"
App:mcv_weekdaytextappearance= "Style"App:mcv_weekdaylabels= "Array"App:mcv_monthlabels= "Array"app:mcv_tilesize= "Dimension"App:mcv_firstdayofweek= "enum"App:mcv_leftarrowmask= "Drawable"App:mcv_rightarrowmask= "Drawable" />

Custom

One goal of this library is to be customizable, with the following options available in Java Code and XML properties:

Property

Type

Describe

Showotherdates

Boolean

By default, only one date is displayed. If set to True, the date of the previous or subsequent month is used to fill the empty space. This property causes the displayed date to exceed the minimum and maximum range of values.

Arrowcolor

Color

Sets the color of the calendar Flip arrow, which is black by default.

SelectionColor

Color

Sets the color of the date selector. By default, more than 5.0 is used in the android:attr/coloraccent, or in the AppCompat library? Attr/coloraccent.

Headertextappearance

Style

Resets the text appearance of the top month indicator.

Weekdaytextappearance

Style

Resets the text appearance of the week indicator.

Datetextappearance

Style

Resets the text appearance of the date.

Weekdaylabels

Array

Provide custom labels for the week. This will set a arrayweekdayformatter for this calendarview. The default is to use the Java Calendar class to get a short display name.

Monthlabels

Array

Provides custom labels for the month. This will set a montharraytitleformatter for this calendarview. The SimpleDateFormat "MMMM yyyy" format is used by default.

Tilesize

Dimension

Set a custom size for each tile. Each day in the calendar is a tile, and the top control bar is a tile high. The entire control is 7 tiles wide and eight tiles high. The default tile size is 44DP.

FirstDayOfWeek

Enum

Set the first day of the month.

Leftarrowmask

Drawable

Sets the drawing effect of the left arrow.

Rightarrowmask

Drawable

Sets the drawing effect of the right arrow.

Properties that are available only in Java:

Method

Description

Setminimumdate ()

Sets the earliest visible date in the calendar.

Setmaximumdate ()

Sets the latest visible date in the calendar.

Setselecteddate ()

Sets the selected date, which must be between the minimum and maximum values.

Settopbarvisible ()

Set the top bar (arrow and caption) to be visible or disappear.

Events, highlighting, custom selectors, and more!

Material CalendarView provides an API that allows you to modify the appearance of dates. The Dayviewdecorator API can do:

Set a custom background image;

Set the custom selected picture;

Use span for full date text (provides Dotspan, draws a point directly below the text);

The set date is not available.

To do this, you need to create a new Dayviewdecorator instance that is added to the calendar through the Adddecorator () method. The adornment effect is done by passing the Dayviewfacade object to the decorate () method. All Dayviewfacade calls are applied to the date that all Shoulddecorate () methods return True.

Dayviewfacade has four methods to provide decorative effects:

1,setbackgrounddrawable () sets a Drawable object to the last party, and this object responds to a change in state.

2,setselectiondrawable () allows you to customize the selection indicator for special dates.

3,addspan () sets span for the entire date label.

4,setdaysdisabled () allows you to disable or re-enable the date. This method does not affect the minimum and maximum dates.

If one of your adorners changes after being added to the Calendar view, make sure you call the Materialcalendarview.invalidatedecorators () method to make these changes effective.

When implementing a Dayviewdecorator object, make sure that they are as efficient as possible. Remember that the Shoulddecorate () method needs to be called 42 times in each month's view. A simple way to improve efficiency is to convert your data outside of the Shoulddecorate () method to CalendarDay.

Check out the basicactivitydecorate in the sample app to learn some examples.

Open Source project material Calendar View Learning record (i)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.