Bhavesh
Bhavesh

Reputation: 79

How to make ⌫ symbol backward-compatible in Android Studio?

The backspace symbol '⌫' gets displayed on my device running the Android API version 28 but not on my emulator running the API version 15. I am using the following code. Please help

<Button
        android:id="@+id/backspace"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="#F5F5F5"
        android:text="\u232b"
        android:textSize="35sp"
        app:layout_column="0"
        app:layout_gravity="fill"
        app:layout_row="0"
        app:layout_rowWeight="1" />

Upvotes: 1

Views: 194

Answers (1)

Mohammed Alaa
Mohammed Alaa

Reputation: 3320

It appears that old android versions doesn't have the font that support this symbol so you have to use a supported font-family for this button you can check supported ones here and use the downloaded font you can check here for how to do that don't forget this section for old apis but here min api-level are 16

and use it like

<Button
    android:id="@+id/backspace"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="#F5F5F5"
    android:text="\u232b"
    android:fontFamily="@font/myfont" //your downloaded font family name
    android:textSize="35sp"
/>

if you need to support api 15 you can use

val typeface = resources.getFont(R.font.myfont)
button.typeface = typeface

Upvotes: 1

Related Questions