代码之家  ›  专栏  ›  技术社区  ›  Al Walid Ashik

在recyclerview滚动中隐藏小部件会留下空白

  •  1
  • Al Walid Ashik  · 技术社区  · 8 年前

    我在屏幕顶部有一个自定义日历视图,当我试图基于recyclerview滚动隐藏该小部件时,该小部件会留下一个空屏幕,如下面的屏幕截图所示

    enter image description here

    上面的calendarView留下了这样的空白

    enter image description here

    这是我的fragment.xml的代码

        <?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="@drawable/gradient_background"
        android:orientation="vertical"
        tools:context=".employer.AttendedFragment">
    
            <com.shrikanthravi.collapsiblecalendarview.widget.CollapsibleCalendar
                android:id="@+id/calendar_view"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:buttonLeft_drawableTintColor="@android:color/white"
                app:buttonRight_drawableTintColor="@android:color/white"
                app:expandIconColor="@color/itemColorDefault"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent"
                app:layout_scrollFlags="scroll|enterAlways"
                app:primaryColor="@color/colorPrimary"
                app:selectedItem_background="@drawable/circle_white_solid_background"
                app:selectedItem_textColor="@color/colorPrimary"
                app:textColor="@android:color/white"
                app:todayItem_background="@drawable/circle_white_stroke_background"
                app:todayItem_textColor="@android:color/white">
    
            </com.shrikanthravi.collapsiblecalendarview.widget.CollapsibleCalendar>
    
        <android.support.v7.widget.RecyclerView
            android:id="@+id/attendance_recyclerview"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_behavior="@string/appbar_scrolling_view_behavior"
            android:clipToPadding="false">
    
        </android.support.v7.widget.RecyclerView>
    
    </LinearLayout>
    

    这就是我隐藏视图的方式

     @Override
                public void onHide() {
                    mCalendarView.animate().translationY(-mCalendarView.getHeight()).setInterpolator(new AccelerateInterpolator(2));
                }
    
                @Override
                public void onShow() {
                    mCalendarView.animate().translationY(0).setInterpolator(new DecelerateInterpolator(2));
                }
    

    请让我知道如何在滚动recyclerView时删除该空白

    1 回复  |  直到 8 年前
        1
  •  0
  •   aolphn    8 年前

    添加动画监听器,将日历视图的可见性设置为动画完成后消失。