• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Subscripts in textview

Can anyone provide some information on how to create subscripted text in a textview in my xml layout?

For example if I wanted to display out H2O and subscript the 2.
 
From java code you can do like this
Code:
textView = (TextView) findViewById(R.id.TextView01);
textView.setText(Html.fromHtml("H<sub>2</sub>O"));


if you want to do this from xml resource add this line in string.xml
Code:
<string name="textViewl">H<sub>2</sub>O</string>

do not forget to add some bottom padding
Code:
android:paddingBottom="5dip"
 
If I add that <sub> to the string resource, it doesn't get recognized. I think it only sees <b>, <i>,<u> as style commands, unless I am doing something wrong.
 
I have tested again.Both ways are working fine at least on emulator.
can you provide some more details like which string your are using , what output you are getting.
 
Back
Top Bottom