后面有ImageView时selectableItemBackground等Drawable消失
selectableItemBackground and other Drawables disappear when there is an ImageView behind
我的 View
层次结构如下所示:
<RelativeLayout>
<ImageView
android:id="@+id/my_background_image"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
androd:id="@+id/my_image"
android:clickable="true"
android:foreground="?attr/selectableItemBackground" />
</LinearLayout>
</RelativeLayout>
如果我将图像 Drawable
设置为 my_background_image
,?attr/selectableItemBackground
在 my_image
上提供的波纹可绘制对象就会消失。不管我使用什么图像,涟漪都完全消失了。我还发现任何 "foreground" Spinner
的背景(包括向下箭头)也消失了。
这是非常奇怪的行为。有谁知道为什么会这样?
编辑: 我想补充一点,只要 src="..."
不包含在背景 ImageView
或 [=19] 中,就会出现波纹=] 没有调用它。
为 LinearLayout
设置透明背景解决了问题。
"Borderless buttons draw their content on the closest background. Your button might not be having background between itself and the ImageView, so it draws underneath the ImageView" 来自
我的 View
层次结构如下所示:
<RelativeLayout>
<ImageView
android:id="@+id/my_background_image"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
androd:id="@+id/my_image"
android:clickable="true"
android:foreground="?attr/selectableItemBackground" />
</LinearLayout>
</RelativeLayout>
如果我将图像 Drawable
设置为 my_background_image
,?attr/selectableItemBackground
在 my_image
上提供的波纹可绘制对象就会消失。不管我使用什么图像,涟漪都完全消失了。我还发现任何 "foreground" Spinner
的背景(包括向下箭头)也消失了。
这是非常奇怪的行为。有谁知道为什么会这样?
编辑: 我想补充一点,只要 src="..."
不包含在背景 ImageView
或 [=19] 中,就会出现波纹=] 没有调用它。
为 LinearLayout
设置透明背景解决了问题。
"Borderless buttons draw their content on the closest background. Your button might not be having background between itself and the ImageView, so it draws underneath the ImageView" 来自