Android textview text get cut off on the sides with custom font

前端 未结 6 1458
误落风尘
误落风尘 2020-12-30 02:01

This is what happens in the preview and on device:

TextView is nothing special, it just loads the custom font:

public class TestTextView extends App         


        
6条回答
  •  感动是毒
    2020-12-30 02:52

    I have encountered the same problem and i found a one liner solution for thouse who are not using the TextView.shadowLayer.

    this is based on the source code that [Dmitry Kopytov] brought here:

    editTextOrTextView.setShadowLayer(editTextOrTextView.textSize, 0f, 0f, Color.TRANSPARENT)
    

    that's it, now the canvas.clipRect in TextView.onDraw() won't cut off the curly font sides.

提交回复
热议问题