android_haibin:calendarview的使用

强大的第三方日历控件

GitHub https://github.com/huanghaibin-dev/CalendarView

juejin https://juejin.im/post/5a6743836fb9a01caa20aefc

使用方法

compile 'com.haibin:calendarview:3.3.9' 

去GitHub看到这个效果一下子就喜欢了,就把代码下了下来了解一下

具体使用

把源代码中的MeiZuActivity MeizuMonthView MeiZuWeekView BaseActivity复制一份 以及你想用的资源文件drawable底下的bg_material.xml bg_ripple.xml  mipmap底下menu_action_calendar_mvp.png  layout底下activity_meizu.xml

layout代码

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="#ffffff"
    android:fitsSystemWindows="true"
    tools:ignore="RtlHardcoded,HardcodedText,RtlSymmetry,SmallSp">
    <android.support.design.widget.CoordinatorLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <RelativeLayout
            android:id="@+id/rl_tool"
            android:layout_width="match_parent"
            android:layout_height="52dp"
            android:background="#FFF">

            <TextView
                android:id="@+id/tv_month_day"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:gravity="center_vertical"
                android:paddingLeft="16dp"
                android:textColor="#000000"
                android:textSize="26sp"
                android:textStyle="bold"
                tools:ignore="RtlSymmetry" />

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:layout_toRightOf="@+id/tv_month_day"
                android:orientation="vertical"
                android:paddingBottom="12dp"
                android:paddingLeft="6dp"
                android:paddingRight="6dp"
                android:paddingTop="12dp"
                tools:ignore="RelativeOverlap">

                <TextView
                    android:id="@+id/tv_year"
                    android:layout_width="wrap_content"
                    android:layout_height="0dp"
                    android:layout_weight="1"
                    android:gravity="center"
                    android:textColor="#000000"
                    android:textSize="10sp" />

                <TextView
                    android:id="@+id/tv_lunar"
                    android:layout_width="wrap_content"
                    android:layout_height="0dp"
                    android:layout_weight="1"
                    android:gravity="center"
                    android:textColor="#000000"
                    android:textSize="10sp"
                    tools:ignore="SmallSp" />
            </LinearLayout>

            <FrameLayout
                android:id="@+id/fl_current"
                android:layout_width="32dp"
                android:layout_height="32dp"
                android:layout_alignParentRight="true"
                android:layout_centerVertical="true"
                android:layout_marginRight="12dp"
                android:background="@drawable/bg_ripple">

                <ImageView
                    android:id="@+id/ib_calendar"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:tint="#000000"
                    android:contentDescription="@string/app_name"
                    android:scaleType="centerInside"
                    android:src="@mipmap/menu_action_calendar_mvp" />

                <TextView
                    android:id="@+id/tv_current_day"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:layout_marginTop="2dp"
                    android:gravity="center"
                    android:text="13"
                    android:textColor="#000000"
                    android:textSize="12sp" />
            </FrameLayout>
        </RelativeLayout>

    <com.haibin.calendarview.CalendarLayout
        android:id="@+id/calendarLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:background="#fff"
        app:default_status="shrink"
        app:calendar_content_view_id="@+id/recyclerView">

        <com.haibin.calendarview.CalendarView
            android:id="@+id/calendarView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="#fff"
            app:calendar_padding="10dp"
            app:current_month_text_color="#333333"
            app:current_month_lunar_text_color="#CFCFCF"
            app:min_year="2004"
            app:max_year="2100"
            app:other_month_text_color="#e1e1e1"
            app:other_month_lunar_text_color="#e1e1e1"
            app:scheme_text="假"
            app:scheme_text_color="#333"
            app:scheme_theme_color="#128c4b"
            app:selected_lunar_text_color="#CFCFCF"
            app:month_view="com.example.iamchan.cal2.MeiZuMonthView"
            app:week_view="com.example.iamchan.cal2.MeizuWeekView"
            app:selected_text_color="#333"
            app:selected_theme_color="#80cfcfcf"
            app:week_background="#fff"
            app:week_text_color="#111111"
            app:week_start_with="sun"
            app:week_view_scrollable="true"
            app:year_view_day_text_color="#333333"
            app:year_view_day_text_size="9sp"
            app:year_view_month_text_color="#ff0000"
            app:year_view_month_text_size="20sp"
            app:month_view_show_mode="mode_only_current"
            app:year_view_scheme_color="#f17706"/>

        <android.support.v7.widget.RecyclerView
            android:id="@+id/recyclerView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"></android.support.v7.widget.RecyclerView>

    </com.haibin.calendarview.CalendarLayout>
    </LinearLayout>
        <android.support.design.widget.FloatingActionButton
            android:id="@+id/add_metting"
            app:backgroundTint="#259b24"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom|end"
            android:layout_margin="16dp"
            app:elevation="8dp"
            android:src="@mipmap/ic_launcher"/>
    </android.support.design.widget.CoordinatorLayout>

</LinearLayout>

注意红色部分month_view和week_view是你的MeizuMonthView MeiZuWeekView路径地址

剩下的就是联动id要一致

我的github https://github.com/woshichan/cal 可以参考一下

 
 

猜你喜欢

转载自blog.csdn.net/iamchan/article/details/81214498