Android TextView superscript

前端 未结 2 544
死守一世寂寞
死守一世寂寞 2021-01-07 07:21

So I\'m trying to add superscipt/subscript to a TextView, basically trying to make a fraction be displayed as 1/2. Not sure where I\'m going wrong, and

2条回答
  •  一个人的身影
    2021-01-07 08:12

    Try Html.fromHtml instead. Simple and precise:

    outputText.setText(Html.fromHtml("" + num + "/" + den + ""));
    

    Note: You may need to give some height to the textview else the output will be clipped.

    Alternatively, you could try this, where the number size is smaller:

    outputText.setText(Html.fromHtml("" + num + "/" + den + ""));
    

提交回复
热议问题