Reputation: 484
<string name="sqr">x<sup>2</sup></string>
and
((Button) findViewById(R.id.sqrBtn)).setText(Html.fromHtml("x<sup>2</sup>"));
these both show:
but it works for TextView. just button have this problem (differs from Subscript and Superscript a String in Android thanks for understanding)
ON:
SM-G920F Galaxy S6 -- Android 6.0.1 (STOCK) - API v23
GT-I9100 Galaxy S2 -- Android 6.0.1 (CM13) - API v23
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
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