将Material Design触摸纹波应用到ImageButton? [英] Apply Material Design Touch Ripple to ImageButton?

查看:73
本文介绍了将Material Design触摸纹波应用到ImageButton?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个imagebutton在单击时不响应触摸动画,因为它是静态图像,不像棒棒糖上的常规按钮带有内置波纹效果.我想在图像上添加材质设计的波纹触摸效果,但似乎找不到实现它的方法.我可以在图像上设置滤色器,但这不是波纹效果.我要尝试执行的一个示例是,当您将专辑封面图像保存在Google Play音乐中时,阴影波纹在图像上移动.

I have an imagebutton that doesn't respond with a touch animation when it is clicked because it is a static image unlike regular buttons on lollipop which come with the built in ripple effect. I would like to add the material design ripple touch effect to the image but can't seem to find a way to implement it. I can set a color filter over the image but that is not the ripple effect. An example of what I'm trying to do is when you hold an album cover image in Google Play Music and a shadow ripple moves across the image.

推荐答案

以获得更好的结果:

<ImageButton
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@android:drawable/ic_button"
    android:background="?attr/selectableItemBackgroundBorderless"
/>

这篇关于将Material Design触摸纹波应用到ImageButton?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆