A material horizontal calendar view for Android based on RecyclerView
.
The library is hosted on jcenter, add this to your build.gradle:
repositories {
jcenter()
}
dependencies {
compile 'devs.mulham.horizontalcalendar:horizontalcalendar:1.3.4'
}
The minimum API level supported by this library is API 14 (ICE_CREAM_SANDWICH).
HorizontalCalendarView
to your layout file, for example:<android.support.design.widget.AppBarLayout>
............
<devs.mulham.horizontalcalendar.HorizontalCalendarView
android:id="@+id/calendarView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
app:textColorSelected="#FFFF"/>
</android.support.design.widget.AppBarLayout>
/* starts before 1 month from now */
Calendar startDate = Calendar.getInstance();
startDate.add(Calendar.MONTH, -1);
/* ends after 1 month from now */
Calendar endDate = Calendar.getInstance();
endDate.add(Calendar.MONTH, 1);
HorizontalCalendar
in your Activity through its Builder:HorizontalCalendar horizontalCalendar = new HorizontalCalendar.Builder(this, R.id.calendarView)
.range(startDate, endDate)
.datesNumberOnScreen(5)
.build();
HorizontalCalendar horizontalCalendar = new HorizontalCalendar.Builder(rootView, R.id.calendarView)
...................
horizontalCalendar.setCalendarListener(new HorizontalCalendarListener() {
@Override
public void onDateSelected(Calendar date, int position) {
//do something
}
});
horizontalCalendar.setCalendarListener(new HorizontalCalendarListener() {
@Override
public void onDateSelected(Calendar date, int position) {
}
@Override
public void onCalendarScroll(HorizontalCalendarView calendarView,
int dx, int dy) {
}
@Override
public boolean onDateLongClicked(Calendar date, int position) {
return true;
}
});
<devs.mulham.horizontalcalendar.HorizontalCalendarView
android:id="@+id/calendarView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:textColorNormal="#bababa"
app:textColorSelected="#FFFF"
app:selectorColor="#c62828" //default to colorAccent
app:selectedDateBackground="@drawable/myDrawable"/>
HorizontalCalendar.Builder
:HorizontalCalendar horizontalCalendar = new HorizontalCalendar.Builder(this, R.id.calendarView)
.range(Calendar startDate, Calendar endDate)
.datesNumberOnScreen(int number) // Number of Dates cells shown on screen (default to 5).
.configure() // starts configuration.
.formatTopText(String dateFormat) // default to "MMM".
.formatMiddleText(String dateFormat) // default to "dd".
.formatBottomText(String dateFormat) // default to "EEE".
.showTopText(boolean show) // show or hide TopText (default to true).
.showBottomText(boolean show) // show or hide BottomText (default to true).
.textColor(int normalColor, int selectedColor) // default to (Color.LTGRAY, Color.WHITE).
.selectedDateBackground(Drawable background) // set selected date cell background.
.selectorColor(int color) // set selection indicator bar's color (default to colorAccent).
.end() // ends configuration.
.defaultSelectedDate(Calendar date) // Date to be selected at start (default to current day `Calendar.getInstance()`).
.build();
builder.configure()
.textSize(float topTextSize, float middleTextSize, float bottomTextSize)
.sizeTopText(float size)
.sizeMiddleText(float size)
.sizeBottomText(float size)
.colorTextTop(int normalColor, int selectedColor)
.colorTextMiddle(int normalColor, int selectedColor)
.colorTextBottom(int normalColor, int selectedColor)
.end()
HorizontalCalendar can display only Months instead of Dates by adding mode(HorizontalCalendar.Mode.MONTHS)
to the builder, for example:
horizontalCalendar = new HorizontalCalendar.Builder(this, R.id.calendarView)
.range(Calendar startDate, Calendar endDate)
.datesNumberOnScreen(int number)
.mode(HorizontalCalendar.Mode.MONTHS)
.configure()
.formatMiddleText("MMM")
.formatBottomText("yyyy")
.showTopText(false)
.showBottomText(true)
.textColor(Color.LTGRAY, Color.WHITE)
.end()
.defaultSelectedDate(defaultSelectedDate)
A list of Events can be provided for each Date which will be represented as circle indicators under the Date with:
builder.addEvents(new CalendarEventsPredicate() {
@Override
public List<CalendarEvent> events(Calendar date) {
// test the date and return a list of CalendarEvent to assosiate with this Date.
}
})
HorizontalCalendar configurations can be changed after initialization:
horizontalCalendar.setRange(Calendar startDate, Calendar endDate);
horizontalCalendar.getDefaultStyle()
.setColorTopText(int color)
.setColorMiddleText(int color)
.setColorBottomText(int color)
.setBackground(Drawable background);
horizontalCalendar.getSelectedItemStyle()
.setColorTopText(int color)
..............
horizontalCalendar.getConfig()
.setSelectorColor(int color)
.setFormatTopText(String format)
.setSizeTopText(float size)
..............
Make sure to call horizontalCalendar.refresh();
when you finish your changes
HorizontalCalendarPredicate
, a unique style for disabled dates can be specified as well with CalendarItemStyle
:builder.disableDates(new HorizontalCalendarPredicate() {
@Override
public boolean test(Calendar date) {
return false; // return true if this date should be disabled, false otherwise.
}
@Override
public CalendarItemStyle style() {
return null; // create and return a new Style for disabled dates, or null if no styling needed.
}
})
horizontalCalendar.selectDate(Calendar date, boolean immediate); // set immediate to false to ignore animation.
// or simply
horizontalCalendar.goToday(boolean immediate);
horizontalCalendar.contains(Calendar date);
Utils.isSameDate(Calendar date1, Calendar date2);
Utils.daysBetween(Calendar startInclusive, Calendar endExclusive);
Contributions are welcome, feel free to submit a pull request.
Copyright 2017 Mulham Raee
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 athttp://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, softwaredistributed 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 governingpermissions and limitations under the License.
This plugin creates a horizontal accordion similar to the blade effect you would encounter on the xBOX360. It uses a simple list as a foundation. Options are available that allow you to alter its beha
使用ScrollView 实现横向滚动的TableView,每个cell的宽度还可以自定义成不同大小,还加入了Cell的可复用机制。使用方法简单,和TableView 差不多。 作者说:目前还不完善,还需进一步改进。大家有意见很欢迎~! 我的邮箱 lovesunstar@sina.com [Code4App.com]
实现水平方向的列表效果。即列表是左右滚动,而不是上下滚动。 [Code4App.com]
实现水平样式的菜单(Horizontal Menu),类似的效果是Three20框架的menubar。菜单位于导航条下方,或者屏幕最下方,有许多按钮在菜单上面。这样的菜单可以在很多新闻类app中出现。适用于有许多分类的内容,用户点击某个菜单按钮,出现某个分类内容。整个效果虽然和Three20框架的menubar差不多,但是实现十分简单,只有不到150行的代码。 [Code4App.com]
The Horizontal Rule (hr) plugin allows a user to insert a horizontal rule on the page at the cursor insertion point. It also adds a toolbar button and a menu item Horizontal line under the Insert menu
应用的资源使用率通常都有高峰和低谷的时候,如何削峰填谷,提高集群的整体资源利用率,让service中的Pod个数自动调整呢?这就有赖于Horizontal Pod Autoscaling了,顾名思义,使Pod水平自动缩放。这个Object(跟Pod、Deployment一样都是API resource)也是最能体现kubernetes之于传统运维价值的地方,不再需要手动扩容了,终于实现自动化了,还