最近开发中需要好多各式各样的控件,其中就有一个是日历控件,网络上的自定义日历控件质量参差不齐,看了好多发现源码中都有bug,加上时间比较紧张,就找了一个普通的日历控件,二次封装了一下,希望能给大家提供帮助。(PS:原谅我技术不太好QAQ,但我觉得应该勉强能入眼吧)
//因为是公司项目不方便给大家放项目源码,所以我尽量写的详细一点QAQ 给你们看下效果图,可以左右滑动切换月份
//导入一个依赖
compile 'com.github.codbking:CalendarExaple:v1.0.0'
//放这部分布局 CardView是那个外面的圆角布局
<android.support.v7.widget.CardView
android:layout_width="335dp"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="25dp"
app:cardCornerRadius="14dp"
app:cardElevation="10dp"
android:layout_gravity="center">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="44dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="选择出行日期"
android:layout_centerVertical="true"
android:layout_marginLeft="15dp"
android:textColor="@color/gray_B1"
android:textSize="@dimen/text_12_sp"/>
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/gray_E2E3E7"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="15dp">
<LinearLayout
android:layout_width="18dp"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:id="@+id/title"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="2016/10/10"
android:textColor="#000"
android:textSize="8sp"/>
</LinearLayout>