【问题标题】:Best way to show Ripple effect in Android在 Android 中显示波纹效果的最佳方式
【发布时间】:2016-02-25 13:21:12
【问题描述】:

我想知道在 Android 中显示涟漪效应的最佳方式是什么。它默认出现在按钮和所有内容中。但是如果我们尝试设置按钮的背景颜色,效果就会消失。

我在堆栈溢出中看到了一些 posts 来创建这种效果。但这是一篇旧文章,Google 会在 XML 文件中添加一些新属性来生成效果。

任何帮助将不胜感激。 提前致谢。

【问题讨论】:

    标签: android


    【解决方案1】:

    在你的drawable文件夹中创建这个xml文件,替换波纹颜色并将其命名为“ripple.xml”:

    <ripple 
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:color="@color/your_ripple_color">
    </ripple>
    

    现在您可以将其应用为背景:

    android:background="@drawable/ripple"
    android:clickable="true"
    

    【讨论】:

    • 这不适用于在 kitkat 和 jellybean 上运行的设备,对吧?
    • 非常感谢齐格勒。
    猜你喜欢
    • 2015-05-17
    • 1970-01-01
    • 1970-01-01
    • 2017-05-01
    • 1970-01-01
    • 2015-06-08
    • 1970-01-01
    • 1970-01-01
    • 2015-01-12
    相关资源
    最近更新 更多