问题
I use a RecyclerView in my grid. Each item has textview and Imageview. I set mask filter for textview in my Adapter as below:
float[] direction = new float[]{0.0f, -1.0f, 0.5f};
MaskFilter maskFilter = new EmbossMaskFilter(direction, 0.8f, 15f, 1f);
holder.textview.getPaint().setMaskFilter(maskFilter);
It is the reason of crash (Fatal signal 11 (SIGSEGV), code 1, fault addr 0xfff8022c in tid 32638 (ReferenceQueueD)
) for the firs time run.
回答1:
This is known bug.
Problem in method canvas.drawText();
But I found a way to avoid crash, by using canvas.drawPath();
instead.
Path path = new Path();
paint.getTextPath( text, 0, text.length(), x, y, path );
canvas.drawPath( path, paint );
If you want to use it in TextView you have to extend this class and create new onDraw method. Enjoy!
来源:https://stackoverflow.com/questions/49578296/how-do-i-setmaskfilter-without-crash-on-android-o