I am making a calculator app in Android Studio(Mac OS) in which I'm trying to include square(x^2) Button
.
I've set my square as a TextView.
I've tried all the links mentioned but none worked for me to type it as in proper equation format.
<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" />
I've also tried below code in MainActivity.java
file:-
squareButton = findViewById(R.id.square);
squareButton.setText(Html.fromHtml("x<sup>2</sup>"));
Examples tried Source 1 Source 2 Didn't work!
P.S. I've set minSdkVersion 14
and targetSdkVersion 26
!