【问题标题】:textallcaps="true" is not working in TextView [Android]textallcaps="true" 在 TextView [Android] 中不起作用
【发布时间】:2021-10-17 12:10:15
【问题描述】:

我的 textallcaps 有问题,在 Android Studio 中显示正常,见图:

但在设备上运行时文本仍为小写,请参见图片:

字体是 Fira GO, 我还尝试了不同的大写字体,但结果仍然相同。 任何想法我怎样才能让它发挥作用?

编辑: 字体 XML:

<?xml version="1.0" encoding="utf-8"?>
 <font-family 
 xmlns:android="http://schemas.android.com/apk/res/android">
 <font
    android:fontStyle="normal"
    android:fontWeight="400"
    android:font="@font/firago_regular" />
  </font-family>

用户界面 XML:

<TextView
            android:textSize="22sp"
            android:textColor="@color/maincolor"
            android:fontFamily="@font/firago"
            android:text="@{pagetitle}"
            android:textAllCaps="true"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content">

        </TextView>

【问题讨论】:

  • 分享你的xml文件
  • @PriyankaRajput 好的,我编辑了问题并添加了 xlm 代码
  • 您刚刚添加了字体系列xml,我们需要检查UI xml
  • @PriyankaRajput 我的错,现在我添加了 Textview,代码
  • 检查 pagetitle 的值,你要为 textview 设置什么。

标签: android view fonts display


【解决方案1】:

https://bboxtype.com/typefaces/FiraGO/(右侧)是 OpenType 印刷功能的列表。这些功能之一是case: case-sensitive forms。 这可以通过在TextView 上应用android:fontFeatureSettings="case" 属性来启用。

这有点棘手,但我认为它会起作用

【讨论】:

    猜你喜欢
    • 2014-12-10
    • 1970-01-01
    • 2015-12-21
    • 2016-09-22
    • 2016-02-22
    • 1970-01-01
    • 2012-11-10
    • 1970-01-01
    • 2016-07-07
    相关资源
    最近更新 更多