android高仿小米日历,高仿钉钉和小米的日历控件
i# 簡(jiǎn)介
這是一個(gè)高仿釘釘和小米的日歷控件,支持快速滑動(dòng),界面緩存。想要定制化UI,使用起來(lái)非常簡(jiǎn)單,就像使用ListView一樣
一些特點(diǎn):
可以自定義日歷控件UI
支持快速滑動(dòng)
支持農(nóng)歷和陽(yáng)歷
界面UI緩存和日歷數(shù)據(jù)緩存
擴(kuò)展view支持listView的滑動(dòng)
左右無(wú)限滑動(dòng)
效果
先上兩張demo的效果圖,分別是仿小米和釘釘日歷效果圖
仿小米日歷
仿釘釘日歷
再看下交互效果
交互動(dòng)畫(huà)
how to use
Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Add the dependency
dependencies {
compile 'com.github.codbking:CalendarExaple:v1.0.0'
}
在layout的xml中添加CalendarLayout和CalendarDateView
注意:CalendarDateView一定是CalendarLayout第一個(gè)view,擴(kuò)展view必須是CalendarDateView第二個(gè)view
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
>
android:id="@+id/calendarDateView"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ffffff"
/>
在你的java文件中設(shè)置CalendarDateView的CaledarAdapter和CalendarView.OnItemClickListener監(jiān)聽(tīng)
注意:想要設(shè)置選中效果,只需設(shè)置CaledarAdapter中的view的選中背景
mCalendarDateView.setAdapter(new CaledarAdapter() {
@Override
public View getView(View convertView, ViewGroup parentView, CalendarBean bean) {
//判斷convertView為null,可以有效利用view的回收重用,左右滑動(dòng)的效率高
if (convertView == null) {
convertView = LayoutInflater.from(parentView.getContext()).inflate(R.layout.item_xiaomi, null);
}
TextView chinaText = (TextView) convertView.findViewById(R.id.chinaText);
TextView text = (TextView) convertView.findViewById(R.id.text);
text.setText("" + bean.day);
//mothFlag 0是當(dāng)月,-1是月前,1是月后
if (bean.mothFlag != 0) {
text.setTextColor(0xff9299a1);
} else {
text.setTextColor(0xff444444);
}
chinaText.setText(bean.chinaDay);
return convertView;
}
});
mCalendarDateView.setOnItemClickListener(new CalendarView.OnItemClickListener() {
@Override
public void onItemClick(View view, int postion, CalendarBean bean) {
mTitle.setText(bean.year + "/" + bean.moth + "/" + bean.day);
}
});
關(guān)于我的其他開(kāi)源項(xiàng)目
聯(lián)系我
總結(jié)
以上是生活随笔為你收集整理的android高仿小米日历,高仿钉钉和小米的日历控件的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: FingerGestures手势插件的使
- 下一篇: 怎么传文件到百度云服务器,别人传文件给我