对于棒棒糖观点连锁反应 [英] Ripple effect for lollipop views
问题描述
我一直在开发棒棒堂(API 21)的应用程序。
在我的按钮
颜色改变的东西,产生的连锁反应不工作。
我发现了一些第三方库的连锁反应,但我想用标准的API做到这一点。
这<一href="http://stackoverflow.com/questions/24607339/lollipop-rippledrawable-vs-selector-for-$p$p-lollipop">answer没有帮助。
XML:
&LT;按钮
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:文本=新按钮
机器人:ID =@ + ID /按钮
机器人:layout_below =@ + ID / TextView的
机器人:背景=@机器人:彩色/ holo_blue_bright
机器人:layout_alignParentStart =真
机器人:layout_marginTop =76dp
/&GT;
您必须在您的按钮的背景设置为RippleDrawable您可以在XML定义。 (我将它命名为 holo_blue_ripple.xml
)
&LT;纹波的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:颜色=@机器人:彩色/白&GT; &LT;! - 纹波颜色 - &GT;
&LT;项目机器人:可绘制=@机器人:彩色/ holo_blue_bright/&GT; &LT;! - 正常的颜色 - &GT;
&LT; /纹波&GT;
然后用引用它的android:背景=@可绘制/ holo_blue_ripple
I have been developing an app for Lollipop (API 21).
When I change the Button
color to something, the ripple effect doesn't works.
I found some third party libraries for the ripple effect, but I want to do this with standard API.
This answer didn't help either.
XML:
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button"
android:layout_below="@+id/textView"
android:background="@android:color/holo_blue_bright"
android:layout_alignParentStart="true"
android:layout_marginTop="76dp"
/>
You have to set your button's background to a RippleDrawable which you can define in XML. (I'll name it holo_blue_ripple.xml
)
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@android:color/white"> <!-- ripple color -->
<item android:drawable="@android:color/holo_blue_bright"/> <!-- normal color -->
</ripple>
Then reference it with android:background="@drawable/holo_blue_ripple"
.
这篇关于对于棒棒糖观点连锁反应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!