Recycler Visibility Changes in MotionLayout

I have a Custom HeaderView and also a RecyclerView.
The Visibility of the RecyclerView is handled Programmatically based on network load/refresh.

Below is a sample of my layout.

<androidx.constraintlayout.motion.widget.MotionLayout
    android:id="@+id/motionLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layoutDescription="@xml/fragment_list_scene"
    android:background="#EAF4FF">

    <View
        android:id="@+id/topColorBar"
        android:layout_width="match_parent"
        android:layout_height="4dp"
        android:layout_gravity="top"
        android:background="@color/colorAccentSecondary"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <com.google.android.material.appbar.AppBarLayout
        android:id="@+id/appbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginStart="6dp"
        android:layout_marginLeft="6dp"
        android:layout_marginTop="16dp"
        android:background="@android:color/transparent"
        android:theme="@style/Theme.Moniepoint.AppBarOverlay"
        app:elevation="0dp"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent">
        <androidx.appcompat.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="@color/transparent"
            app:contentInsetEnd="0dp"
            app:contentInsetEndWithActions="0dp"
            app:contentInsetStart="0dp"
            app:layout_scrollFlags="scroll|enterAlways"
            app:popupTheme="@style/Theme.Moniepoint.PopupOverlay"
            app:title="Account"
            app:titleTextColor="@color/colorPrimaryDark" />
    </com.google.android.material.appbar.AppBarLayout>

    <BalanceCardView
        android:id="@+id/balanceContainer"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginStart="42dp"
        android:layout_marginEnd="42dp"
        app:balanceCardViewModel="@{viewModel}"
        app:cardCornerRadius="20dp"
        app:cardElevation="32dp"
        app:layout_constraintVertical_bias="0.1"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toBottomOf="@id/appbar" />

   <View
        android:id="@+id/curvedBackground"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_marginTop="0dp"
        android:background="@drawable/dashboard_content_bg"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/contentGuide" />

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/transactionList"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:orientation="vertical"
        android:paddingTop="120dp"
        android:clipToPadding="false"
        app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="@id/curvedBackground" />

</androidx.constraintlayout.motion.widget.MotionLayout>

And Below is my scene layout.

<ConstraintSet android:id="@+id/start">
    <Constraint android:id="@+id/balanceContainer"
        >
        <CustomAttribute
            app:attributeName="radius"
            app:customDimension="16dp"
            />
    </Constraint>
    <Constraint
        android:id="@+id/shimmerLayout"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="@id/curvedBackground"
        app:visibilityMode="ignore"
        />

    <Constraint
        android:id="@+id/transactionList"
        >
        <PropertySet
            app:visibilityMode="ignore"
            />
    </Constraint>
</ConstraintSet>

<ConstraintSet android:id="@+id/end">
    <Constraint
        android:id="@id/balanceContainer"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        app:layout_constraintVertical_bias="0.0"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/appbar"
        >
        <CustomAttribute
            app:attributeName="radius"
            app:customDimension="0dp"
            />
    </Constraint>
    <Constraint
        android:id="@+id/transactionList"
        app:visibilityMode="ignore"
        />
</ConstraintSet>

<Transition
    app:constraintSetStart="@id/start"
    app:constraintSetEnd="@id/end"
    app:duration="3000"
    >
    <OnSwipe
        app:touchAnchorId="@id/transactionList"
        app:touchAnchorSide="right"
        app:dragDirection="dragUp"
    />
</Transition>
  • The RecylerView Still doesn’t show with the above implementation
  • If i give the layout definitions of recyclerView on the ConstraintStart and ConstraintEnd
    The recyclerView displays but the animation doesn’t run, meaning, it completes very fast
    regardless of the duration.

I’m really not sure what i’m to do at this point.

Source: Android Questions

LEAVE A COMMENT