textview cutting off a letter in android

前端 未结 11 2312
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-18 12:56

\"http://dl.dropbox.com/u/24856/Screenshots/android/cutoff.png\"

this is a screen shot from my android. the text is

11条回答
  •  离开以前
    2021-02-18 13:19

    I encountered the same problem but with EditText when used some fonts. My solution works also with TextView:

    1. Use padding

    2. As TextView using Canvas.clipRect(float, float, float, float) in onDraw method to crop - create custom Canvas class and override this method (leave it empty).

    3. Next сreate custom TextView and override two methods onSizeChanged and onDraw.

    In onSizeChanged create bitmap with the size of TextView and our custom Canvas.

    In onDraw first draw in bitmap by passing our custom Canvas to method super.onDraw. After that draw bitmap to target сanvas.

    More detailed in my answer to the similar question here

提交回复
热议问题