WeekCalendar - 一個簡單的Android周日歷
WeekCalendar - 一個簡單的Android周日歷
The sample project includes the usage of the library. Support for Android 4.0 and up.
Demo
Setup
Gradle
dependencies {
compile 'noman.weekcalendar:weekcalendar:1.0.6'
}
Maven
<dependency> <groupId>noman.weekcalendar</groupId> <artifactId>weekcalendar</artifactId> <version>1.0.6</version> </dependency>
Sample Usage
<noman.weekcalendar.WeekCalendar
android:id="@+id/weekCalendar"
android:layout_width="match_parent"
android:layout_height="65dp"
android:background="@color/colorPrimary"/> Theme the calendar
There are a few xml attributes to customise the calendar. If you feel that any customization option is missing, let me know.
numOfPagesdaysTextSizedaysTextColordaysBackgroundColorweekTextSizeweekTextColorweekBackgroundColorselectedBgColortodaysDateBgColordayNameLengthhideNames
Example
<noman.weekcalendar.WeekCalendar android:id="@+id/weekCalendar" android:layout_width="match_parent" android:layout_height="65dp" android:background="@color/colorPrimary" app:numOfPages="150" app:dayNameLength="threeLetters" app:todaysDateBgColor="#ffffff"/>
Explained
numOfPagesby default, calendar has 100 pages. You can scroll 49 to left and 49 to right. Using this attribute you can set number of pages. You can send it to 1000, it depends on requirements.daysTextSizeday means day of the month. By default text size is17sp.daysTextColorby default the day text color is set to be white.daysBackgroundColorif you havecolorPrimaryattribute incolor.xml, then the backgroud color will be that one. Otherwise the purple color shown in the demo.weekTextSizeweek means day of the week,i.e (S,M,T ..). By default text size is17sp.weekTextColorby default the week day text color is set to be white.weekBackgroundColorsame asdaysBackgroundColorselectedBgColorBy default, its color is set to becolorAccent, if you've that attribute in attribute incolor.xml, then the backgroud color will be that one. Otherwise the pink color shown in the demo.todaysDateBgColortodays date background color, same asselectedBgColor.dayNameLengthweek day name length,singleLettermeans (S,M,T..) andthreeLettersmeans (Sun, Mun, Tue..)hideNames, set this attribute to hide name of week days.
Impelement Listener
OnDateClickListener returns DateTime object. DateTime is class available in Joda Time. I will recommend using this library if you are playing with date and time.
weekCalendar.setOnDateClickListener(new OnDateClickListener() {
@Override
public void onDateClick(DateTime dateTime) {
Toast.makeText(MainActivity.this,
"You Selected " + dateTime.toString(), Toast.LENGTH_SHORT).show();
}
}); See the sample project for usage of methods like
reset()moveToNext()moveToPrevious()setSelectedDate(DateTime)setStartDate(DateTime)
Libraries Used
License
Copyright (c) 2015 Noman Rafique 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.
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!

