在引用Android L的RippleDrawable https://developer.android.com/reference/android/graphics/drawable/RippleDrawable.html时,有一种方法可以屏蔽掉视图中的涟漪效果。掩蔽完成
<ripple android:color="#ff0000ff">
<item android:drawable="@drawable/white" />
</ripple>
我们也可以使用
来掩饰它<ripple android:color="#ff0000ff">
<item android:drawable="@drawable/black" />
</ripple>
如文件中所述,屏幕上没有绘制遮罩层,只是掩盖了涟漪效应。我很好奇,为什么要在那里设置一种颜色(白色或黑色或任何东西)?我们是否有任何重要的颜色作为面具,或者它确实会有任何价值吗?
希望有人启发......谢谢!
答案 0 :(得分:7)
为您的面具使用不透明颜色 - 无论Filter expression for filtering listed resources, in the form filter={expression}. Your {expression} must contain the following:
FIELD_NAME COMPARISON_STRING LITERAL_STRING
FIELD_NAME: The name of the field you want to compare. The field name must be valid for the type of resource being filtered. Only atomic field types are supported (string, number, boolean). Array and object fields are not currently supported. For example, if you search for machineType in the Firewalls collection, the filter will fail, because the machineType field is specific to instances and other resources do not have that property.
COMPARISON_STRING: The comparison string, either eq (equals) or ne (not equals).
LITERAL_STRING: The literal string value to filter to. The literal value must be valid for the type of field (string, number, boolean). For string fields, the literal value is interpreted as a regular expression using RE2 syntax. The literal value must match the entire field. For example, when filtering instances by name, name eq my-instance won't work, but name eq .*my-instance will work.
For example, for Operation resources, you could filter by the type of the operation:
filter=operationType ne insert
The above filter returns only results whose type field does not equal insert. You can also enclose your literal string in single, double, or no quotes. For example, all three of the following would be valid expressions:
filter=operationType ne "insert"
filter=operationType ne 'insert'
filter=operationType ne insert
If you use a complex regular expression, you need to encode the special characters, including quotes. Consider the following regular expression:
target eq 'example-name-[0-9]+'
To use the expression, you would need to encode it:
filter=target+eq+%27example-name-%5B0-9%5D%2B%27
If you are using the API through a client, such as client libraries, or gcloud compute, keep in mind that your client might encode your regular expression automatically so that you will not need to encode it yourself.
,@android:color/white
或#ff000000
是否无关紧要 - 意味着您正在屏蔽完全不透明的矩形,与您的drawable大小相同。它是纹波掩模最有效的渲染路径。