From d10680187d69bb42edf2d9f17262965033acf289 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Sun, 9 Aug 2020 22:04:09 -0700 Subject: [PATCH] Nest CardView with alpha in another FrameLayout RecyclerView animator will mess with alpha when animating Check this StackOverflow question for more info: https://stackoverflow.com/questions/40942116/setalpha-on-onbindview-in-recyclerview-doesnt-work-on-first-display --- app/src/main/res/layout/item_module_md2.xml | 234 ++++++++++---------- 1 file changed, 119 insertions(+), 115 deletions(-) diff --git a/app/src/main/res/layout/item_module_md2.xml b/app/src/main/res/layout/item_module_md2.xml index 2da734425..08f209d55 100644 --- a/app/src/main/res/layout/item_module_md2.xml +++ b/app/src/main/res/layout/item_module_md2.xml @@ -19,132 +19,136 @@ - + android:layout_height="wrap_content"> - - - - - - - - - - - - - + android:alpha="@{item.enabled ? 1f : .5f}" + android:onClick="@{() -> item.toggle()}" + tools:layout_gravity="center" + tools:layout_margin="@dimen/l1"> + android:layout_height="match_parent" + android:layout_gravity="center" + android:adjustViewBounds="true" + android:alpha=".05" + android:background="@null" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintLeft_toLeftOf="parent" + app:layout_constraintTop_toTopOf="parent" + app:tint="?colorOnSurface" + tools:srcCompat="@drawable/ic_update_md2" /> - + android:animateLayoutChanges="true"> - + - + + + + + + + + + + + + + + + +