Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set text in textview very blurry

Tags:

android

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 very inefficient. Anyone who has a better solution?

like image 359
K Roobroeck Avatar asked May 16 '13 11:05

K Roobroeck


2 Answers

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);
like image 56
theczechsensation Avatar answered Nov 18 '22 22:11

theczechsensation


You should try to use canvas instead of TextView and draw a text with blur. There is a lot of method using BlurMaskFilter and you can use this like that :

paint.setMaskFilter(new BlurMaskFilter(float radius, BlurMaskFilter.Blur style));
like image 4
vmathieu Avatar answered Nov 18 '22 22:11

vmathieu