美文网首页
Android水波点击效果

Android水波点击效果

作者: Singleton丶 | 来源:发表于2017-12-04 17:35 被阅读0次

先在Drawable文件下创建两个文件用作背景

rounded_corners.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <solid android:color="#FFFFFF" />
    <corners android:radius="4dp" />
</shape>

ripple_bg.xml:

<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
    android:color="#33000000">
    <item>
        <shape android:shape="rectangle">
            <solid android:color="#FFFFFF" />
            <corners android:radius="4dp" />
        </shape>
    </item>
    <item android:drawable="@drawable/rounded_corners" />
</ripple>

最后在对应的view上指定

android:background="@drawable/ripple_bg"

注意:以上方法仅支持Android5.0以上版本

相关文章

网友评论

      本文标题:Android水波点击效果

      本文链接:https://www.haomeiwen.com/subject/unixixtx.html