【问题标题】:How to show Unicode character in a TextView in Android?如何在 Android 的 TextView 中显示 Unicode 字符?
【发布时间】:2021-10-24 14:16:33
【问题描述】:

我想在我的 android 应用程序的文本视图中显示 Unicode。我搜索了一个解决方案,但没有任何帮助。 我想在Kotlin 中以编程方式执行此操作,因为我想将它与从 Firestore 获取的数据连接起来。

【问题讨论】:

    标签: android kotlin unicode


    【解决方案1】:

    首先,检查您使用的字体是否支持 Unicode。 然后您可以按照@Anshul 的建议使用Html.fromHtml,但请记住它已被弃用,您需要按照Unicode characters not displayed in TextView.setText 中的建议使用Html.FROM_HTML_MODE_LEGACY

    【讨论】:

      【解决方案2】:

      您可以使用 HTML 之类的库将 unicode 从 html 解析为字符串

      val bullet = "&#8226"
      print("this is bullet a ${Html.fromHtml(bullet)}")
      

      【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-12-01
      • 2016-08-25
      • 1970-01-01
      • 1970-01-01
      • 2011-08-28
      • 2014-09-28
      • 2014-05-26
      • 2018-01-23
      相关资源
      最近更新 更多