How to adjust line height in TextView with multiple type sizes?

后端 未结 4 457
既然无缘
既然无缘 2021-01-31 17:54

I have a TextView that holds a Spannable string. The string contains a bunch of text, the first word of which is double the typesize as the rest of the string.

The prob

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-31 18:44

    I think you can't :(. Android os calculate the gaps between the lines according the font size, so that '30$' makes gap between line 1 and line 2 to be bigger, and I do not know if it is possible to control this gap size.

    To solve this you can easily extend LinearLayuot and put the orientation vertical. Than put 2 textviews with fillparent for width....

    and than implement function , let say setNoGapText(String s); , and in this function you can measure the text that can be fit in the textview on the top(this can me done with textutils), and than the rest of the text will be fit on textview2...

    between this textview you can play with padding and margins properties so the gaps between lines will look just like you imagine them.

提交回复
热议问题