I'm animating my recycler view so that it slides side-to-side, exposing a checkbox on the left. The initial animation is great, but when the list is longer than the device height, we get issues with where the two elements (the date and the horizontal rule) are placed. I've recorded two videos to demonstrate the bug in more detail.
Goal: How do I prevent the dates from zig-zagging like that?
Here's the parent recycler view:
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerview_vins"
android:layout_width="0dp"
android:layout_height="0dp"
android:paddingStart="-46dp"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
And here's the view holder for each list item:
<android.support.constraint.ConstraintLayout 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:id="@+id/front_layout_read_mode"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<CheckBox
android:id="@+id/is_selected_checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:button="@drawable/checkbox_selector"
android:checked="false"
android:scaleX="0.5"
android:scaleY="0.5"
app:layout_constraintEnd_toStartOf="@+id/year_make_model_text_view"
app:layout_constraintTop_toTopOf="@+id/year_make_model_text_view" />
<TextView
android:id="@+id/year_make_model_text_view"
style="@style/VinListYearMakeModel"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="64dp"
android:layout_marginTop="24dp"
app:layout_constraintEnd_toStartOf="@+id/date_text_view"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="1998 Honda Fit blahblahblahblahblahblahblahblahblahblahblah" />
<TextView
android:id="@+id/vin_text_view"
style="@style/VinListVin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAllCaps="false"
app:layout_constraintStart_toStartOf="@+id/year_make_model_text_view"
app:layout_constraintTop_toBottomOf="@+id/year_make_model_text_view"
tools:text="4JHG2J43HJHG34" />
<TextView
android:id="@+id/date_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/year_make_model_text_view"
tools:text="03/14/18" />
<TextView
android:id="@+id/horizontal_rule"
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_marginTop="24dp"
android:background="#E1E1E1"
android:textSize="20sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/vin_text_view" />
</android.support.constraint.ConstraintLayout>
And here's the gist of the animation that slides the recycler view side-to-side:
val aul = AnimatorUpdateListener {
Log.i("Animated Value", it.animatedValue.toString())
recyclerview_vins.setPadding(it.animatedValue as Int, 0 ,0 ,0)
}
val varl = ValueAnimator.ofInt(0, -137) // These values reversed for opposite animation
varl.duration = 400
varl.addUpdateListener(aul)
varl.start()
I think it may be related to other bugs having to do with the last item in a recycler view list behaving weirdly: