title: chemistry formula on Android
body: <p>I'm developing an android project and I want to render some chemistry formula.</p>
  
  <p>I wrote the following code and I got the following result.</p>
  
  <p>I create a custom string and show it in a textview.</p>
  
  <p>But my question is this: Is this the best way to do this?  And is there another way to handle that?</p>
  
  <pre><code>str = new SpannableString(Html.fromHtml("2H&lt;sup&gt;+&lt;/sup&gt; + So&lt;sub size = 2&gt;4&lt;/sub&gt;&lt;sup size = 2&gt;2-&lt;/sup&gt; --&gt; H&lt;sub size =2&gt;2&lt;/sub&gt;So&lt;sub size = 2&gt;4&lt;/sub&gt;"));
  ss1.setSpan(new RelativeSizeSpan(0.6f), 2,3, 0); // set size
  ss1.setSpan(new RelativeSizeSpan(0.6f), 8,11, 0); // set size
  ss1.setSpan(new RelativeSizeSpan(0.6f), 17,18, 0); // set size
  ss1.setSpan(new RelativeSizeSpan(0.6f), 20,21, 0); // set size
  TempF.setText(ss1,TextView.BufferType.SPANNABLE);
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/ocZ9p.jpg" alt="Example Chemical Formula"></p>