如何使 ⌫ 符号在 Android Studio 中向后兼容?
How to make ⌫ symbol backward-compatible in Android Studio?
退格符号“⌫”显示在我的设备 运行 Android API 版本 28 上,但不显示在我的模拟器 运行 API版本 15。我正在使用以下代码。请帮助
<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" />
看来旧的 android 版本没有支持这个符号的字体所以你必须为这个按钮使用支持的 font-family 你可以检查支持的 here
并使用下载的字体,你可以检查 here for how to do that don't forget this 部分的旧 apis 但这里最小 api-level 是 16
并像
一样使用它
<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"
/>
如果需要支持api15可以使用
val typeface = resources.getFont(R.font.myfont)
button.typeface = typeface
退格符号“⌫”显示在我的设备 运行 Android API 版本 28 上,但不显示在我的模拟器 运行 API版本 15。我正在使用以下代码。请帮助
<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" />
看来旧的 android 版本没有支持这个符号的字体所以你必须为这个按钮使用支持的 font-family 你可以检查支持的 here 并使用下载的字体,你可以检查 here for how to do that don't forget this 部分的旧 apis 但这里最小 api-level 是 16
并像
一样使用它<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"
/>
如果需要支持api15可以使用
val typeface = resources.getFont(R.font.myfont)
button.typeface = typeface