0

environment: Android 4.2

layout/activity_main.xml

<EditText
    android:id="@+id/et_content"
    android:background="#AAAAAA"
    android:layout_width="match_parent"
    android:textSize="40sp"
    android:layout_height="match_parent"
    android:gravity="left|top" >

    <requestFocus />
</EditText>

Testing 1 (SUCCESS! has effect):

SpannableStringBuilder spanText = SpannableStringBuilder.valueOf("abcdefghijklmnopqrstuvwxyz");
MaskFilterSpan maskFilterSpan = new MaskFilterSpan(new BlurMaskFilter(3, Blur.OUTER));
spanText.setSpan(maskFilterSpan, 0, spanText.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
etContent.setText(spanText);

Testing 2 (Failure! no effect, Why ??? ):

String str = etContent.getText().toString();
SpannableStringBuilder spanText = SpannableStringBuilder.valueOf(str);
MaskFilterSpan maskFilterSpan = new MaskFilterSpan(new BlurMaskFilter(3, Blur.OUTER));
spanText.setSpan(maskFilterSpan, 0, etContent.length(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
etContent.setText(spanText);

Difference is that the second paragraph of the code is the data obtained from EditText. second code use String str = etContent.getText().toString(); I tried before the first piece of code add the code editText.setText("123456"), and found also failed blur effect.

Who can help me?

1 Answers1

1

It renders correctly if you set android:hardwareAccelerated="false" on your Activity in AndroidManifest.xml.

BlurMaskFilter is not supported with hardware acceleration.

http://developer.android.com/guide/topics/graphics/hardware-accel.html

flav
  • 593
  • 6
  • 10