How to make RelativeSizeSpan align to top

后端 未结 9 2137
情深已故
情深已故 2021-01-31 03:14

I have the following String RM123.456. I would like to

  • Make RM relatively smaller
  • Make RM aligned to to
9条回答
  •  爱一瞬间的悲伤
    2021-01-31 03:24

    you have to used html tag like below for subscript and superscript.It works like charm.

     ((TextView) findViewById(R.id.text)).setText(Html.fromHtml("2X"));
    

    or

    You can also use below code:

    String titleFirst = "Insert GoTechTM device into the vehicle\'s OBDII port.";
    SpannableStringBuilder cs = new SpannableStringBuilder(titleFirst);
    cs.setSpan(new SuperscriptSpan(), titleFirst.indexOf("TM"), titleFirst.indexOf("TM")+2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    cs.setSpan(new RelativeSizeSpan((float)0.50), titleFirst.indexOf("TM"), titleFirst.indexOf("TM")+2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);        
    txtPairInstructionFirst.setText(cs);
    

提交回复
热议问题