title: How to clear formatting of a Spannable Text, including last character?
body: <p>I am using this code to remove formatting of a spannable text from start till end. The problem is that it is working successfully, but the last character in the text is still bold (or italics/underline).</p>
  
  <p><code>removeSpan</code> is not working on the last character in the text:</p>
  
  <pre><code>int startSelection = 0;
  int endSelection = text.length();
  if(startSelection &gt; endSelection) {
      startSelection  = text.getSelectionEnd();
      endSelection = text.getSelectionStart();
  }
  
  Spannable str = text.getText();
  StyleSpan[] ss = str.getSpans(startSelection, endSelection, StyleSpan.class);
  for (int i = 0; i &lt; ss.length; i++) {
      if (ss[i].getStyle() == android.graphics.Typeface.BOLD) {
          str.removeSpan(ss[i]);
      }
      if (ss[i].getStyle() == android.graphics.Typeface.ITALIC) {
          str.removeSpan(ss[i]);
      }
  }
  
  UnderlineSpan[] ulSpan = str.getSpans(startSelection, endSelection, UnderlineSpan.class);
  for (int i = 0; i &lt; ulSpan.length; i++) {
      str.removeSpan(ulSpan[i]);
  }
  
  str.removeSpan(ss[1]);
  
  text.setText(str);
  </code></pre>