【发布时间】:2018-12-04 02:16:42
【问题描述】:
我有一个有趣的问题,我有一个 ImageButton(没有高程),我在 ImageButton 上方放置了一个图像。它看起来像;
但是,如果我将高度设置为 ImageButton(cd image),绿色圆圈将转到 ImageButton 的后面。带高程的图像;
有人知道为什么以及如何解决这个问题吗?我无法弄清楚这个问题。感谢大家,这是我的 XML 代码;
<ImageButton
android:id="@+id/imageButton2"
android:layout_width="@dimen/preset_share_button_width"
android:layout_height="@dimen/preset_share_button_height"
android:layout_marginBottom="50dp"
android:layout_marginStart="32dp"
android:adjustViewBounds="false"
android:background="@drawable/preset_share_icon_background"
android:cropToPadding="false"
android:elevation="6dp"
android:scaleType="centerInside"
android:src="@drawable/add_tone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/imageButton3"
app:layout_constraintStart_toStartOf="parent" />
<ImageView
android:layout_width="25dp"
android:layout_height="25dp"
android:background="@drawable/tick_background"
android:scaleType="center"
android:src="@drawable/tick_icon"
app:layout_constraintBottom_toTopOf="@+id/imageButton2"
app:layout_constraintEnd_toEndOf="@+id/imageButton2"
app:layout_constraintStart_toEndOf="@+id/imageButton2"
app:layout_constraintTop_toTopOf="@+id/imageButton2" />
<TextView
style="@style/defaultText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:text="Add Tone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@+id/imageButton2"
app:layout_constraintHorizontal_bias="0.555"
app:layout_constraintStart_toStartOf="@+id/imageButton2"
app:layout_constraintTop_toBottomOf="@+id/imageButton2" />
【问题讨论】:
-
在你的第二个 ImageView 中尝试 android:elevation="8dp"。
-
我认为这与我尝试但没有奏效的海拔值无关。还是谢谢。
-
你的父布局是什么?
-
我正在与
ConstraintLayout合作 -
我刚刚在我的代码中尝试过,这是一个海拔问题。我将高程设置为与第一张图像(CD 图像)相同或更高的第二张图像(绿色复选标记)。它奏效了。
标签: android android-imagebutton android-elevation