MaskFilterSpan

滤镜样式。

MaskFilterSpan(MaskFilter filter)

MaskFilter提供了两个子类:

BlurMaskFilter用来制作模糊效果。

EmbossMaskFilter用来制作浮雕效果。

示例1:

BlurMaskFilter blurMaskFilter = new BlurMaskFilter(3, BlurMaskFilter.Blur.OUTER);
MaskFilterSpan maskFilterSpan = new MaskFilterSpan(blurMaskFilter);

String text = "打开百度";
SpannableString spannableString = new SpannableString(text);
spannableString.setSpan(maskFilterSpan, 0, text.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);

TextView textView = (TextView) findViewById(R.id.text_view);
textView.setText(spannableString);

示例2:

EmbossMaskFilter embossMaskFilter = new EmbossMaskFilter(new float[]{10, 10, 10}, 0.5f, 1f, 1f));
MaskFilterSpan maskFilterSpan = new MaskFilterSpan(embossMaskFilter);

String text = "打开百度";
SpannableString spannableString = new SpannableString(text);
spannableString.setSpan(maskFilterSpan, 0, text.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);

TextView textView = (TextView) findViewById(R.id.text_view);
textView.setText(spannableString);