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:
parent
f5aa6a3cf8
commit
d10680187d
@ -19,132 +19,136 @@
|
||||
|
||||
</data>
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
style="@style/WidgetFoundation.Card.Variant"
|
||||
isEnabled="@{!item.removed}"
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:alpha="@{item.enabled ? 1f : .5f}"
|
||||
android:onClick="@{() -> item.toggle()}"
|
||||
tools:layout_gravity="center"
|
||||
tools:layout_marginBottom="@dimen/l1"
|
||||
tools:layout_marginEnd="@dimen/l1">
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/module_state_icon"
|
||||
gone="@{!item.removed && !item.updated}"
|
||||
srcCompat="@{item.removed ? R.drawable.ic_delete_md2 : (item.updated ? R.drawable.ic_update_md2 : 0)}"
|
||||
android:layout_width="wrap_content"
|
||||
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" />
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
style="@style/WidgetFoundation.Card.Variant"
|
||||
isEnabled="@{!item.removed}"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:animateLayoutChanges="true">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/module_title"
|
||||
strikeThrough="@{item.removed}"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/l1"
|
||||
android:layout_marginTop="@dimen/l1"
|
||||
android:layout_marginEnd="@dimen/l_50"
|
||||
android:text="@{item.item.name}"
|
||||
android:textAppearance="@style/AppearanceFoundation.Body"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintEnd_toStartOf="@+id/module_indicator"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:text="@tools:sample/lorem" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/module_version_author"
|
||||
strikeThrough="@{item.removed}"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@{@string/module_version_author(item.item.version, item.item.author)}"
|
||||
android:textAppearance="@style/AppearanceFoundation.Caption.Variant"
|
||||
app:layout_constraintEnd_toEndOf="@+id/module_title"
|
||||
app:layout_constraintStart_toStartOf="@+id/module_title"
|
||||
app:layout_constraintTop_toBottomOf="@+id/module_title"
|
||||
tools:text="v1 by topjohnwu" />
|
||||
|
||||
<com.google.android.material.switchmaterial.SwitchMaterial
|
||||
android:id="@+id/module_indicator"
|
||||
android:checked="@={item.enabled}"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/l_50"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/module_version_author"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="1"
|
||||
app:layout_constraintStart_toEndOf="@+id/module_info"
|
||||
app:layout_constraintTop_toTopOf="@+id/module_title" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/module_description"
|
||||
gone="@{item.item.description.empty}"
|
||||
strikeThrough="@{item.removed}"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/l1"
|
||||
android:layout_marginTop="@dimen/l1"
|
||||
android:layout_marginEnd="@dimen/l1"
|
||||
android:text="@{item.item.description}"
|
||||
android:textAppearance="@style/AppearanceFoundation.Caption.Variant"
|
||||
app:layout_constraintTop_toBottomOf="@+id/module_version_author"
|
||||
tools:lines="4"
|
||||
tools:text="@tools:sample/lorem/random" />
|
||||
|
||||
<View
|
||||
android:id="@+id/module_divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginTop="@dimen/l1"
|
||||
android:background="?colorSurfaceSurfaceVariant"
|
||||
app:layout_constraintTop_toBottomOf="@+id/module_description" />
|
||||
android:alpha="@{item.enabled ? 1f : .5f}"
|
||||
android:onClick="@{() -> item.toggle()}"
|
||||
tools:layout_gravity="center"
|
||||
tools:layout_margin="@dimen/l1">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/module_info"
|
||||
style="@style/WidgetFoundation.Icon"
|
||||
gone="@{item.repo == null}"
|
||||
android:id="@+id/module_state_icon"
|
||||
gone="@{!item.removed && !item.updated}"
|
||||
srcCompat="@{item.removed ? R.drawable.ic_delete_md2 : (item.updated ? R.drawable.ic_update_md2 : 0)}"
|
||||
android:layout_width="wrap_content"
|
||||
android:alpha=".5"
|
||||
android:onClick="@{() -> viewModel.infoPressed(item)}"
|
||||
android:paddingEnd="@dimen/l_50"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/module_remove"
|
||||
app:layout_constraintEnd_toStartOf="@+id/module_remove"
|
||||
app:layout_constraintTop_toTopOf="@+id/module_remove"
|
||||
app:srcCompat="@drawable/ic_info" />
|
||||
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" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/module_remove"
|
||||
style="@style/WidgetFoundation.Button.Text"
|
||||
android:layout_width="wrap_content"
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:onClick="@{(v) -> item.delete(viewModel)}"
|
||||
android:text="@{item.removed ? @string/module_state_restore : @string/module_state_remove}"
|
||||
android:textAllCaps="false"
|
||||
app:icon="@{item.removed ? R.drawable.ic_restart : R.drawable.ic_delete_md2}"
|
||||
app:iconGravity="textEnd"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/module_divider"
|
||||
tools:icon="@drawable/ic_delete_md2"
|
||||
tools:text="Remove" />
|
||||
android:animateLayoutChanges="true">
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
<TextView
|
||||
android:id="@+id/module_title"
|
||||
strikeThrough="@{item.removed}"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/l1"
|
||||
android:layout_marginTop="@dimen/l1"
|
||||
android:layout_marginEnd="@dimen/l_50"
|
||||
android:text="@{item.item.name}"
|
||||
android:textAppearance="@style/AppearanceFoundation.Body"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintEnd_toStartOf="@+id/module_indicator"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:text="@tools:sample/lorem" />
|
||||
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
<TextView
|
||||
android:id="@+id/module_version_author"
|
||||
strikeThrough="@{item.removed}"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@{@string/module_version_author(item.item.version, item.item.author)}"
|
||||
android:textAppearance="@style/AppearanceFoundation.Caption.Variant"
|
||||
app:layout_constraintEnd_toEndOf="@+id/module_title"
|
||||
app:layout_constraintStart_toStartOf="@+id/module_title"
|
||||
app:layout_constraintTop_toBottomOf="@+id/module_title"
|
||||
tools:text="v1 by topjohnwu" />
|
||||
|
||||
<com.google.android.material.switchmaterial.SwitchMaterial
|
||||
android:id="@+id/module_indicator"
|
||||
android:checked="@={item.enabled}"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/l_50"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/module_version_author"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="1"
|
||||
app:layout_constraintStart_toEndOf="@+id/module_info"
|
||||
app:layout_constraintTop_toTopOf="@+id/module_title" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/module_description"
|
||||
gone="@{item.item.description.empty}"
|
||||
strikeThrough="@{item.removed}"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/l1"
|
||||
android:layout_marginTop="@dimen/l1"
|
||||
android:layout_marginEnd="@dimen/l1"
|
||||
android:text="@{item.item.description}"
|
||||
android:textAppearance="@style/AppearanceFoundation.Caption.Variant"
|
||||
app:layout_constraintTop_toBottomOf="@+id/module_version_author"
|
||||
tools:lines="4"
|
||||
tools:text="@tools:sample/lorem/random" />
|
||||
|
||||
<View
|
||||
android:id="@+id/module_divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginTop="@dimen/l1"
|
||||
android:background="?colorSurfaceSurfaceVariant"
|
||||
app:layout_constraintTop_toBottomOf="@+id/module_description" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/module_info"
|
||||
style="@style/WidgetFoundation.Icon"
|
||||
gone="@{item.repo == null}"
|
||||
android:layout_width="wrap_content"
|
||||
android:alpha=".5"
|
||||
android:onClick="@{() -> viewModel.infoPressed(item)}"
|
||||
android:paddingEnd="@dimen/l_50"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/module_remove"
|
||||
app:layout_constraintEnd_toStartOf="@+id/module_remove"
|
||||
app:layout_constraintTop_toTopOf="@+id/module_remove"
|
||||
app:srcCompat="@drawable/ic_info" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/module_remove"
|
||||
style="@style/WidgetFoundation.Button.Text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:onClick="@{() -> item.delete(viewModel)}"
|
||||
android:text="@{item.removed ? @string/module_state_restore : @string/module_state_remove}"
|
||||
android:textAllCaps="false"
|
||||
app:icon="@{item.removed ? @drawable/ic_restart : @drawable/ic_delete_md2}"
|
||||
app:iconGravity="textEnd"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/module_divider"
|
||||
tools:icon="@drawable/ic_delete_md2"
|
||||
tools:text="Remove" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
</layout>
|
||||
|
Loading…
Reference in New Issue
Block a user