android高仿小米日历,高仿钉钉和小米的日历控件
i# 簡介
這是一個高仿釘釘和小米的日歷控件,支持快速滑動,界面緩存。想要定制化UI,使用起來非常簡單,就像使用ListView一樣
一些特點:
可以自定義日歷控件UI
支持快速滑動
支持農歷和陽歷
界面UI緩存和日歷數據緩存
擴展view支持listView的滑動
左右無限滑動
效果
先上兩張demo的效果圖,分別是仿小米和釘釘日歷效果圖
仿小米日歷
仿釘釘日歷
再看下交互效果
交互動畫
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第一個view,擴展view必須是CalendarDateView第二個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文件中設置CalendarDateView的CaledarAdapter和CalendarView.OnItemClickListener監聽
注意:想要設置選中效果,只需設置CaledarAdapter中的view的選中背景
mCalendarDateView.setAdapter(new CaledarAdapter() {
@Override
public View getView(View convertView, ViewGroup parentView, CalendarBean bean) {
//判斷convertView為null,可以有效利用view的回收重用,左右滑動的效率高
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是當月,-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);
}
});
關于我的其他開源項目
聯系我
總結
以上是生活随笔為你收集整理的android高仿小米日历,高仿钉钉和小米的日历控件的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: FingerGestures手势插件的使
- 下一篇: 怎么传文件到百度云服务器,别人传文件给我