0

I've a custom calendar view placed at the top of screen and when i'm trying to hide that widget based on recyclerview scrolling, the widget leaves an empty screen like below screenshots

enter image description here

and the above calendarView leaves a blank space like this

enter image description here

here is the code of my 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>

and this how I'm hiding the views

 @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));
            }

Please let me know how can i remove that blank space when scrolling the recyclerView

Al Walid Ashik
  • 1,545
  • 20
  • 32
  • Changing translation does not trigger layout updates, that's why they are so smooth compared to animating layout parameters. For any measurement and layout purposes, your calendar view is still there and `RecyclerView` will keep the distance. You might need to use a layout transition, or add extra size + padding to `RecyclerView` and animate it's transition alongside calendar. – Pawel Oct 27 '18 at 21:18

1 Answers1

0

Add animate listener, set calender view's visibility to GONE after your amimation is complete.

aolphn
  • 2,950
  • 2
  • 21
  • 30