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
This commit is contained in:
topjohnwu 2020-08-09 22:04:09 -07:00
parent f5aa6a3cf8
commit d10680187d

View File

@ -19,6 +19,10 @@
</data> </data>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.card.MaterialCardView <com.google.android.material.card.MaterialCardView
style="@style/WidgetFoundation.Card.Variant" style="@style/WidgetFoundation.Card.Variant"
isEnabled="@{!item.removed}" isEnabled="@{!item.removed}"
@ -27,8 +31,7 @@
android:alpha="@{item.enabled ? 1f : .5f}" android:alpha="@{item.enabled ? 1f : .5f}"
android:onClick="@{() -> item.toggle()}" android:onClick="@{() -> item.toggle()}"
tools:layout_gravity="center" tools:layout_gravity="center"
tools:layout_marginBottom="@dimen/l1" tools:layout_margin="@dimen/l1">
tools:layout_marginEnd="@dimen/l1">
<ImageView <ImageView
android:id="@+id/module_state_icon" android:id="@+id/module_state_icon"
@ -132,10 +135,10 @@
style="@style/WidgetFoundation.Button.Text" style="@style/WidgetFoundation.Button.Text"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:onClick="@{(v) -> item.delete(viewModel)}" android:onClick="@{() -> item.delete(viewModel)}"
android:text="@{item.removed ? @string/module_state_restore : @string/module_state_remove}" android:text="@{item.removed ? @string/module_state_restore : @string/module_state_remove}"
android:textAllCaps="false" android:textAllCaps="false"
app:icon="@{item.removed ? R.drawable.ic_restart : R.drawable.ic_delete_md2}" app:icon="@{item.removed ? @drawable/ic_restart : @drawable/ic_delete_md2}"
app:iconGravity="textEnd" app:iconGravity="textEnd"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/module_divider" app:layout_constraintTop_toBottomOf="@+id/module_divider"
@ -146,5 +149,6 @@
</com.google.android.material.card.MaterialCardView> </com.google.android.material.card.MaterialCardView>
</FrameLayout>
</layout> </layout>