Reputation: 15646
Android Studio 2.6
I want ImageView to be OVER MaterialCardView.
I try this
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/cardPaymentContainer"
android:layout_width="0dp"
android:layout_height="200dp"
android:layout_margin="@dimen/default_margin"
android:layout_marginStart="@dimen/button_margin"
android:layout_marginEnd="@dimen/button_margin"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/toolBarContainer">
<com.google.android.material.card.MaterialCardView
android:id="@+id/cardPaymentCardView"
style="@style/cardViewIconStyle"
android:layout_width="0dp"
android:layout_height="0dp"
android:checkable="true"
android:clickable="true"
android:focusable="true"
app:cardCornerRadius="@dimen/card_view_cornder_radius"
app:checkedIcon="@drawable/ic_credit_card_outline_select"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
</com.google.android.material.card.MaterialCardView>
<ImageView
android:id="@+id/cardPaymentImageViewContainer"
android:layout_width="72dp"
android:layout_height="72dp"
android:background="@drawable/card_payment_view_bg"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
Here result:
As you can see it's not work.
The ImageView is UNDER MaterialCardView.
Upvotes: 0
Views: 58
Reputation: 15423
You have to modify the default Z Axis behavior of CardView by updating elevation. set cardElevation
to 0dp.
app:cardElevation="0dp"
Upvotes: 1