RippleDrawable面膜颜色是什么? [英] RippleDrawable mask color, what is it for?

查看:133
本文介绍了RippleDrawable面膜颜色是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在提及Android L的RippleDrawable时, https://developer.android.com/reference/android/graphics/drawable/RippleDrawable.html 中,有一种方法可以掩盖视图中的波纹效果.遮罩的完成方式是

In referring to the RippleDrawable for Android L, https://developer.android.com/reference/android/graphics/drawable/RippleDrawable.html, there's a way to mask away to contain the ripple effect within the view. The masking is done as

<ripple android:color="#ff0000ff">
    <item android:drawable="@drawable/white" />
</ripple>

我们也可以使用

<ripple android:color="#ff0000ff">
    <item android:drawable="@drawable/black" />
</ripple>

如文档中所述,遮罩层不是在屏幕上绘制的,而只是掩盖了波纹效果.我很好奇,为什么要在那里设置一种颜色(白色或黑色或其他颜色)?我们是否有任何重要意义将颜色设置为遮罩",或者确实有任何值可以做到?

As mentioned in the document, the mask layer is not drawn on the screen, but just masking away the ripple effect. I'm curious, why should one set a color (White or Black or anything) there? Is there any significant of us setting a color as the Mask, or it is indeed any value will do?

希望有人启发...谢谢!

Hopes someone enlighten... thanks!

推荐答案

使用不透明的颜色作为蒙版-不管是@android:color/white#ff000000还是#ff123456都不重要-表示您正在蒙版与完全不透明的矩形相对应,该矩形与您的可绘制对象具有相同的大小.这是波纹遮罩的最有效渲染路径.

Using an opaque color for your mask -- whether that's @android:color/white, #ff000000, or #ff123456 doesn't matter -- means you are masking against a fully opaque rectangle that is the same size as your drawable. It's the most efficient rendering path for ripple masks.

这篇关于RippleDrawable面膜颜色是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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