【发布时间】:2015-03-23 16:47:54
【问题描述】:
我想在 Android Lollipop 的通知中为 ImageView / ImageButton 添加波纹效果。我看到这在 Google Play 音乐上是可能的。但是,我在其他视图中使用的解决方案不适用于通知。
我在 drawable-v21 中创建了 RippleDrawable
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="#33000000">
</ripple>
并将这个drawable设置为ImageView的背景
<ImageView android:id="@+id/notification_play_button"
tools:src="@drawable/av_play_over_video"
android:layout_width="32dp"
android:layout_height="32dp"
android:background="@drawable/button_selector_semi_black"
/>
但它根本不起作用。你有什么想法如何实现这个效果?
【问题讨论】:
-
我怀疑您想要一个在单击按钮时应用波纹的
<selector>(StateListDrawable)。 -
@CommonsWare 我试图将
<selector>与<item android:state_pressed="true" android:drawable="@drawable/button_selector_semi_black">相加,其中button_selector_semi_black是我的涟漪,没有任何效果:( 可能为时已晚,而且我失明了:/ -
如果您在模拟器上进行测试,AFAIK 您需要打开主机 GPU 模式才能看到效果。我不能在我的 Ubuntu 设置上使用主机 GPU 模式(虽然我最近没有尝试过,所以也许他们修复了这个错误),但要看到涟漪,我必须在 Android 5.0 硬件上进行测试。
-
我正在使用 Android 5.0.0 和 HTC One GPE 测试 Genymotion 和 5.0.1 ;/
-
棉花糖中的相同。您是否在问题跟踪器中提出了错误报告?
标签: android android-notifications android-5.0-lollipop rippledrawable