Ebrahim Tahernejad
Ebrahim Tahernejad

Reputation: 484

superscript <SUP> tag not working

<string name="sqr">x<sup>2</sup></string>

and

((Button) findViewById(R.id.sqrBtn)).setText(Html.fromHtml("x<sup>2</sup>"));

these both show:

SUP tag not working

but it works for TextView. just button have this problem (differs from Subscript and Superscript a String in Android thanks for understanding)

ON:

Additional info:

Tag:

<Button  style="@style/calcBtn"
         android:text="@string/sqr"
         android:id="@+id/sqrBtn" />

Style:

<style name="calcBtn">
    <item name="android:layout_width">match_parent</item>
    <item name="android:layout_height">wrap_content</item>
    <item name="android:textSize">35sp</item>
    <item name="android:layout_weight">1</item>
    <item name="android:textColor">#f2f2f2</item>
    <item name="android:background">#282828</item>
    <item name="android:paddingTop">12dp</item>
    <item name="android:paddingBottom">12dp</item>
</style>

Upvotes: 1

Views: 1281

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006549

Try android:textAllCaps="false" on the Button. By default, on Theme.Material and Theme.AppCompat, you get all caps, which breaks any formatting you attempt to apply to the Button text.

Upvotes: 3

Related Questions