Superscript and Subscript on Button in Android Studio - android-studio

I am making a Scientific Calculator in Android Studio. I need to write x^2 as Superscipt and etc like this in Button text. How to do it?
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/btnX2"
android:text=
>
</Button>
Here in text what should I write?

Related

The color does not show correct in the design view of android studio

The background color in design view of android studio is not correct
This is my color.xml
The color of the button "=" is Orange and I do not set any color to the rest of buttons, but all button show purple in Design view
Did you change the theme? You can make your own theme (just a suggestion).
Or use AppCompatButton, example:
<androidx.appcompat.widget.AppCompatButton
android:id="#+id/yourButton"
android:layout_width="200dp"
android:layout_height="45dp"
android:layout_marginTop="15dp"
android:background="#drawable/rounded_corners"
android:backgroundTint="#color/white"
android:contextClickable="false"
android:linksClickable="false"
android:text="Your text"
android:textStyle="bold"
android:textColor="#color/black"
app:layout_constraintCircleRadius="20dp"
app:rippleColor="#FFFFFF" />

Android Studio Changing Button Background Color

I have started learning Android Studio and I am trying to change my button's background, but it is just not working.
Here is my code:
<Button
android:layout_width="300dp"
android:layout_height="200dp"
android:text="salam"
android:textSize="30sp"
android:textColor="#ffccee"
android:background="#ffffff"
/>
The background color stays the same after I change it.
So actually for some reason now Button only follows the colour which is in the theme of your activity but instead of going and messing with theme use AppCompatButton
<androidx.appcompat.widget.AppCompatButton
android:layout_width="300dp"
android:layout_height="200dp"
android:text="salam"
android:textSize="30sp"
android:textColor="#ffccee"
android:background="#ffffff">
</androidx.appcompat.widget.AppCompatButton>
Keep in mind even in future I would recommend using AppCompatButton.

How to remove box and add only underline like the old style for android TextInputLayout in android studio

I want to create the following without setting the style to legacy because it creates other problems for example for AutoCompleteTextView.
style="#style/Widget.Design.TextInputLayout"
You can use app:boxBackgroundColor="#android:color/transparent" on FilledBox style TextInputLayout to only have an underline without the box.
Like this :
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/outlinedTextField"
style="#style/Widget.MaterialComponents.TextInputLayout.FilledBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:boxBackgroundColor="#android:color/transparent"
android:hint="label">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
</com.google.android.material.textfield.TextInputLayout>
And if you want to remove both box and underline use this : app:boxBackgroundMode="none"

Android Studio Edit Text prints wrong input in the Emulator

When I provide input to the Edit Text from my Laptop Keyboard, it prints (takes wrong input) jargon.
For example typing "London" from my Keyboard prints "øóñðóñ". The number "12345" print as "²²¤€"
I have tried changing the Edit Text multiple times but no use. The input from the emulator keyboard prints just fine. There was no error like this a few hours ago.
The code for Edit Text xml:
<EditText
android:id="#+id/cityText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="80dp"
android:layout_marginLeft="80dp"
android:layout_marginTop="40dp"
android:layout_marginEnd="80dp"
android:layout_marginRight="80dp"
android:ems="10"
android:inputType="textPersonName"
android:text="Name"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView" />
Solved it. Some combination of Ctrl+Alt+Shift+Left Arrow Key works!

Ellipsize Radio button label in Android

I am working on an Android native app where I have a radio button group as given below side by side.
[radio btn] Option 1 [radio btn] Option 2
Now the problem is I'm supporting few languages and the radio btn labels are larger in some languages. Hence I want to ellipsize these labels so that they are always aligned on a single line. Any suggestions.
You can use android:ellipsize="end" and android:singleLine="true" properties as below,
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:singleLine="true" />

Resources