问题描述
我已经阅读材料设计准则,但我不知道应该是什么纹波的颜色,如果它不黑(阿尔法)。
I have reading Material Design Guidelines but I don't know what should be the color of the Ripple if it isn't black (with alpha).
例如,我有colorPrimary =蓝色的应用程序,并colorAccent =红色。其实我现在用的是colorAccent(阿尔法),我应该用colorPrimary(阿尔法),如果我想要一个颜色不同的黑色纹波?
For example, I have an app with colorPrimary = blue, and colorAccent = red. Actually I am using the colorAccent (with alpha), I should use colorPrimary (with alpha) if I want a color different of black to the ripple?
我检查了谷歌的所有应用程序,但他们从来没有使用涟漪颜色。
I checked all app of Google but they never use ripples with color.
就像我现在有一个形象:
An image like I have now:
推荐答案
使用26%的α-有色涟漪。
Use 26% alpha for colored ripples.
Android的大号不支持主题颜色状态列表属性和<纹波>
元素没有alpha通道,但对于有界的涟漪,你可以做是这样的:
Android L doesn't support theme attributes in color state lists and the <ripple>
element doesn't have an alpha channel, but for bounded ripples you can do something like:
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="?android:attr/colorAccent">
<item android:id="@android:id/mask">
<color android:color="#42ffffff" />
</item>
</ripple>
一个无界的脉动这将无法正常工作。另外,既然你知道你自己的口音的颜色,你可以定义一个26%的alpha版本,或使用颜色状态列表。无论是这些将正常工作为一个无限涟漪。
This won't work for an unbounded ripple. Alternatively, since you know your own accent color, you can either define a 26% alpha version or use a color state list. Either of these will work fine for an unbounded ripple.
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/accent_26" />
RES /价值/ colors.xml:
res/values/colors.xml:
<resources>
...
<color name="accent">#ff33b5e5</color>
<color name="accent_alpha26">#4233b5e5</color>
</resources>
RES /颜色/ accent_alpha26.xml:
res/color/accent_alpha26.xml:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/accent"
android:alpha="0.26" />
</selector>
这篇关于应该是什么涟漪,colorPrimary或colorAccent的颜色? (材料设计)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!