Android 芯片 View 不使用 android :textAllCaps ="true" 大写字母

标签 android material-components material-components-android android-chips

我已将 Chip 动态膨胀并添加到 ChipGroup 中:

<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.chip.Chip xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    style="@style/Widget.MaterialComponents.Chip.Choice"
    android:layout_width="wrap_content"
    android:layout_height="24dp"
    android:checkable="false"
    android:clickable="true"
    android:ellipsize="end"
    android:focusable="true"
    android:letterSpacing="0.02"
    android:maxLines="1"
    android:textColor="#515968"
    android:textSize="12sp"
    android:textAllCaps="true"
    app:chipBackgroundColor="#00000000"
    app:chipCornerRadius="3dp"
    app:chipStrokeColor="#a6aab1"
    app:chipStrokeWidth="1dp"/>

不通过 android:textAllCaps="true"

将字母大写

Non-capitalized

Chip 继承自 TextView 所以它应该可以工作。 https://material.io/components/chips/#action-chips没有显示大写的示例,尽管我看不出有任何不这样做的理由。

我可能犯了什么错误?我没有看到任何内容。

最佳答案

事实证明,textAllCaps确实有效,但是......以编程方式。

viewHolder.someProviders.addView((LayoutInflater.from(viewHolder.someProviders.context)
    .inflate(R.layout.name_of_layout, viewHolder.someProviders, false) as Chip)
    .apply {
        text = provider.name
        isAllCaps = true
    })

关于Android 芯片 View 不使用 android :textAllCaps ="true" 大写字母,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58398611/

相关文章:

Android - Open GL ES ...我可以从哪里开始?

java - 不使用接口(interface)的 fragment 之间的通信

ios - MDCSnackbarManager buttonFont 不工作

android - TextAppearance.MaterialComponents.Body2 的定义?

android - 如何通过代码圆化 AlertDialog 的角

javascript - 上传多个文件时,HTML5 媒体捕获在 Android 上崩溃

java - 速度测试应用程序 下载 上传 Ping

Android Material Chip 主题覆盖

java - Material Components 主题无法正确渲染 TextButton

java - 尽管我可以使用 MaterialButton,但无法使用 MaterialButtonToggleGroup?