首先.xml 界面布局如下
<Button
android:id="@+id/shopDepositBtn"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginTop="12dp"
android:layout_marginStart="0dp"
android:layout_marginEnd="0dp"
android:text="@string/shopsetting_shopdeposit"
android:paddingStart="15dp"
android:textSize="16sp"
android:gravity="center_vertical"
android:background="@color/white"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/shopAuthenticationBtn"/>
<ImageView
android:id="@+id/shopDepositImageV"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_marginTop="15dp"
android:layout_marginBottom="15dp"
android:layout_marginEnd="15dp"
app:layout_constraintBottom_toBottomOf="@+id/shopDepositBtn"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/shopDepositBtn"
android:src="@drawable/arrow"
tools:ignore="ContentDescription"/>
其中布局效果图:
模拟器/真机运行效果图:
分析:通过调整图片大小猜测:是因为图片被遮盖,所以显示不出来。
而被遮盖的原因是因为:
默认button 下会有阴影效果,不仅抬升了button 的位置,而且把Button的优先级提高了(原来button 和imageview 同等级,imageView后添加,理论上可以覆盖在Button上,但是有阴影效果的button 优先级是提高了,所以会覆盖在imageview上方)
解决方法:
在Button里面添加属性:
android:stateListAnimator="@null"
效果如下: