0

I'll try to keep it simple, but it's two part.

In my Android app, I have a textview anf 4 buttons (question and 4 answers). I'm attempting to utilize the html <sub>subscript</sub> and <sup>superscript</sup>. It's working on the textivew (ie. the text is formatted the way I want it to be), but when I try to do the same thing on the buttons in the exact same way, it doesn't format them. X2 just becomes "X2" without superscript.

Why is this the case and how can I get it to work on the buttons like it works on the textview?

If it helps, I noticed something. If I pull the same string to the textview and to the buttons (keep in mind I'm pulling the strings from a variable set in a java structure I made... questions/answers I coded into arrays), the textview will read "Question # 1" and the button will read "QUESTION # 1". So, somehow the button is formatting the text and I wasn't aware of that. Could this be the reason the <sub> html code isn't working on the buttons? What's causing this and how can I fix it?

Thank you.

lilgodwin
  • 1,098
  • 3
  • 13
  • 26
  • Are you using `Html.fromHtml`? – ρяσѕρєя K Mar 23 '15 at 05:18
  • See [this answer](http://stackoverflow.com/questions/29007746/button-settext-with-spannable-dosent-work-for-android-5-0-lollipop) regarding spannables and `android:allCaps`. – alanv Mar 23 '15 at 05:33
  • @ρяσѕρєяK yeah I am using Html.fromHtml. On the textview it works. Using the exact same method on the button, it doesn't work. And on top of that, the same string is produced but in all caps. So I'm thinking some other form of formatting is going on with the button. Whether I placed it there somehow I don't know. But in my XML file the button doesn't have any formatting attributes. Will do alanv. – lilgodwin Mar 23 '15 at 16:05
  • @alanv Thank you! I upvoted your answer to the link you sent. It was exactly the issue. Along with CommonsWare, you guys really helped me out in explaining what was going on and how to fix it. The new default (I suppose 5.0) forces all caps. Though I must make note, it's not `android:allCaps = "false";` but rather `android:textAllCaps = "false";` Now the HTML subscript and other formatting techniques work on the buttons too. Thanks again! – lilgodwin Mar 23 '15 at 16:11
  • Thanks, updated the linked response to have to the correct `android:textAllCaps` attribute. – alanv Mar 23 '15 at 18:14

0 Answers0