如何使Studio符号在Android Studio中向后兼容? [英] How to make ⌫ symbol backward-compatible in Android Studio?

查看:105
本文介绍了如何使Studio符号在Android Studio中向后兼容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在运行Android API版本28的设备上显示退格符号'⌫',但在运行API版本15的模拟器上却不显示退格符号.我正在使用以下代码.请帮助

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" />

推荐答案

看来,旧的android版本没有支持该符号的字体,因此您必须使用受支持的 font-family 对于此按钮,您可以在此处并使用下载的字体,您可以在此处,请不要忘记部分适用于旧版api,但此处 api级最低为 16

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

并像使用它

<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"
/>

如果您需要支持api 15,则可以使用

if you need to support api 15 you can use

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

这篇关于如何使Studio符号在Android Studio中向后兼容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆