Set text in textview very blurry

后端 未结 3 581
萌比男神i
萌比男神i 2021-01-05 08:41

I\'m looking into methods of completely blurring a text in a textview. Read, completely unreadable (pixelate). The methods i\'m using now are using shadows. But this seems v

3条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-05 09:40

    I did not like the Paint method used in the other answers. The below code is working for me with the radius calculated depending on the font size and applying it directly on the TextView.

    if (Build.VERSION.SDK_INT >= 11) {
         yourTextView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
    }
    float radius = yourTextView.getTextSize() / 3;
    BlurMaskFilter filter = new BlurMaskFilter(radius, BlurMaskFilter.Blur.NORMAL);
    yourTextView.getPaint().setMaskFilter(filter);
    

提交回复
热议问题