title: How to type x^2 (subscript and superscript) in TextView
body: <p>I am making a calculator app in Android Studio(Mac OS) in which I'm trying to include <strong>square(x^2)</strong> <code>Button</code>.
  I've set my square as a TextView.</p>
  
  <p>I've tried all the links mentioned but none worked for me to type it as in proper equation format.</p>
  
  <pre><code>&lt;TextView
      android:id="@+id/square"
      style="?android:attr/borderlessButtonStyle"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_gravity="top"
      android:layout_marginBottom="-3dp"
      android:layout_marginLeft="-20dp"
      android:layout_marginStart="-5dp"
      android:padding="15dp"
      android:textColor="@color/black"
      android:textSize="18sp" /&gt;
  </code></pre>
  
  <p>I've also tried below code in <code>MainActivity.java</code> file:-</p>
  
  <pre><code>squareButton = findViewById(R.id.square);
  squareButton.setText(Html.fromHtml("x&lt;sup&gt;2&lt;/sup&gt;"));
  </code></pre>
  
  <p>Examples tried
  <a href="https://stackoverflow.com/questions/7726659/how-to-write-the-to-the-power-and-some-text-like-as-shown-in-java-or-android">Source 1</a> <a href="https://stackoverflow.com/questions/16156032/android-string-resource-superscript/22105902#22105902">Source 2</a> Didn't work!</p>
  
  <p>P.S. I've set <code>minSdkVersion 14</code>  and <code>targetSdkVersion 26</code>!</p>