我已将 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"
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/