RippleDrawable mask color, what is it for?

血红的双手。 提交于 2019-11-30 16:45:56

问题


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>

We could also mask it using

<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!


回答1:


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.



来源:https://stackoverflow.com/questions/30556160/rippledrawable-mask-color-what-is-it-for

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!