huanghaibin-dev / CalendarView

Android上一个优雅、万能自定义UI、仿iOS、自定义动画,支持垂直、水平方向切换、支持周视图、自定义周起始、性能高效的日历控件,支持热插拔实现的UI定制!支持标记、自定义颜色、农历、自定义月视图各种显示模式等。Canvas绘制,速度快、占用内存低,你真的想不到日历居然还可以如此优雅!An elegant, highly customized and high-performance Calendar Widget on Android.
Apache License 2.0
9.09k stars 1.78k forks source link

recycleview加一个刷新的 layout 就出问题了 #595

Open StormBugMe opened 4 years ago

StormBugMe commented 4 years ago

recycleview加一个刷新的 layout 就出问题了

StormBugMe commented 4 years ago

<?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:background="#ffffff" android:fitsSystemWindows="true" android:orientation="vertical" tools:context="com.haibin.calendarviewproject.MainActivity" tools:ignore="RtlHardcoded,HardcodedText,RtlSymmetry,SmallSp">

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

    <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:paddingLeft="6dp"
        android:paddingTop="12dp"
        android:paddingRight="6dp"
        android:paddingBottom="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:contentDescription="@string/app_name"
            android:scaleType="centerInside"
            android:src="@mipmap/ic_calendar"
            android:tint="#000000" />

        <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:background="#fff"
    android:orientation="vertical"
    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_lunar_text_color="#CFCFCF"
        app:current_month_text_color="#333333"
        app:max_year="2020"
        app:min_year="2004"
        app:month_view="com.haibin.calendarviewproject.custom.CustomMonthView"
        app:month_view_show_mode="mode_fix"
        app:other_month_lunar_text_color="#e1e1e1"
        app:other_month_text_color="#e1e1e1"
        app:scheme_text="假"
        app:scheme_text_color="#333"
        app:scheme_theme_color="#128c4b"
        app:selected_lunar_text_color="#fff"
        app:selected_text_color="#fff"
        app:selected_theme_color="#046cea"
        app:week_background="#fff"
        app:week_start_with="sun"
        app:week_text_color="#e1e1e1"
        app:week_view="com.haibin.calendarviewproject.custom.CustomWeekView"
        app:year_view="com.haibin.calendarviewproject.custom.CustomYearView"
        app:year_view_day_text_color="#333333"
        app:year_view_day_text_size="7sp"
        app:year_view_month_text_color="#ff0000"
        app:year_view_month_text_size="20sp"
        app:year_view_scheme_color="#f17706"
        app:year_view_select_text_color="#fff"
        app:year_view_week_height="12dp"
        app:year_view_week_text_color="#e1e1e1"
        app:year_view_week_text_size="6sp" />

    <com.lcodecore.tkrefreshlayout.TwinklingRefreshLayout
        android:id="@+id/rf"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/recyclerView"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
    </com.lcodecore.tkrefreshlayout.TwinklingRefreshLayout>
</com.haibin.calendarview.CalendarLayout>

huanghaibin-dev commented 4 years ago

参考pager包,要嵌套使用TwinklingRefreshLayout要实现CalendarLayout的接口,并指定id为rf

loyilin commented 4 years ago

参考pager包,要嵌套使用TwinklingRefreshLayout要实现CalendarLayout的接口,并指定id为rf

怎么实现CalendarLayout的接口呢? 文档里没看到

loyilin commented 4 years ago

在你的项目中找到了答案,实现CalendarLayout.CalendarScrollView接口,重写isScrollToTop()方法,问题解决了 @huanghaibin-dev

stustatic commented 2 years ago

我是在CalendarLayout中将mContentView = findViewById(mContentViewId);变为mContentView = findViewById(R.id.rf);就可以了,无需重写或实现接口