直接上代碼:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/iv_head_photo"
android:layout_width="@dimen/PX_100"
android:layout_height="@dimen/PX_100"
android:layout_marginTop="@dimen/PX_10"
android:layout_marginRight="@dimen/PX_10"
android:elevation="@dimen/PX_6"
android:padding="@dimen/PX_1"
android:scaleType="fitXY"
android:src="@drawable/sp_head_bg"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tv_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Chen Zong"
android:textColor="@color/font_11"
android:textSize="@dimen/PX_24"
app:layout_constraintEnd_toEndOf="@id/iv_head_photo"
app:layout_constraintStart_toStartOf="@id/iv_head_photo"
app:layout_constraintTop_toBottomOf="@id/iv_head_photo" />
<ImageView
android:id="@+id/iv_touxiang_close"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/ico_touxiang_close"
android:translationZ="@dimen/PX_100"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
關鍵代碼屬性上浮的圖片ImageView的屬性 translationZ值設置的大一點就好了