如何使用支持库在Android中实现纹波动画 [英] How to achieve ripple animation using support library in Android

查看:150
本文介绍了如何使用支持库在Android中实现纹波动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好我想补充的纹波动画按钮的点击。我不喜欢下面,但它需要的minSdkVersion 21。

Hi I am trying to add ripple animation on button click. I did like below but it requires minSdKVersion to 21.

ripple.xml

ripple.xml

<ripple xmlns:android="http://schemas.android.com/apk/res/android"
    android:color="?android:colorControlHighlight">
    <item>
        <shape android:shape="rectangle">
            <solid android:color="?android:colorAccent" />
        </shape>
    </item>
</ripple>

按钮

<com.devspark.robototextview.widget.RobotoButton
    android:id="@+id/loginButton"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/ripple"
    android:text="@string/login_button" />

我希望把它向后兼容也是,所以我想用支持库。我没有找到任何计算器后这一点。

I want to make it backward compatible also so i want to use support library. I didn't find any post on stackoverflow for this.

任何想法,任何人这可怎么办呢?

Any idea to anyone how this can be do ?

在此先感谢。

推荐答案

我以前投关闭这个问题作为题外话,但实际上我改变了主意,因为这是相当不错的视觉效果,不幸的是,还没有的一部分支持库。这将极有可能在以后的更新显示,但有没有宣布的时间框架。

I formerly voted to close this question as off-topic but actually I changed my mind as this is quite nice visual effect which, unfortunately, is not yet part of support library. It will most likely show up in future update, but there's no time frame announced.

幸运的是有一些自定义的实现已经可用:

Luckily there are few custom implementations already available:

  • https://github.com/traex/RippleEffect
  • https://github.com/balysv/material-ripple
  • https://github.com/siriscac/RippleView
  • https://github.com/ozodrukh/RippleDrawable

包括Materlial为主题的小工具设置与旧版本的Andr​​oid兼容的:

including Materlial themed widget sets compatible with older versions of Android:

  • <一个href="https://github.com/keithellis/MaterialWidget">https://github.com/keithellis/MaterialWidget

所以你可以尝试其中的一个或谷歌等材料部件左右...

so you can try one of these or google for other "material widgets" or so...

这篇关于如何使用支持库在Android中实现纹波动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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