android - 使用 setText() 时,芯片文本重叠图标
问题描述
我正在使用android.support.design.chip.Chip,我得到的问题是,当我通过setText("...")动态设置文本时,文本通过重叠图标错误地出现,但是当我设置它时xml 文件为app:chipText="Hello"它显示正确。
在这里你有我的代码:
活动.java:
Chip x= new Chip(mView);
x.setChipDrawable(ChipDrawable.createFromResource(mView, R.xml.chip_style));
芯片样式.xml:
<?xml version="1.0" encoding="utf-8"?>
<chip xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
style="@style/Widget.MaterialComponents.Chip.Entry"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="@style/TextAppearance.MaterialComponents.Chip"
app:chipIcon="@drawable/ic_person"/>
- - - - - - - - - - -解决方案 - - - - - - - - - - -
然后,解决方案是使用芯片方法setChipText(CharSequence text)
解决方案
我终于注意到了我的错误,我正在使用:
trabajador.setText(FunctionsUtil.safeCursorGetValue(trabajadorData, KEY_NOMBRE));
代替:
trabajador.setChipText(FunctionsUtil.safeCursorGetValue(trabajadorData, KEY_NOMBRE));
然后,解决方案是使用芯片方法setChipText(CharSequence text)
推荐阅读
- python - How do I assign values to an array depending on condition (MATLAB→Python translation)
- javascript - How do I make 2 checkboxes, that if for example one is checked and then you try to check the other it cancel the first one?
- variables - Create Varilable as Boolean in RDLC report to represent if dollar sign should be printed or not
- flutter - ICE Connection failed for webrtc in flutter
- python - kubernetes.client.rest.ApiException:(401)原因:未经授权;创建/删除 GKE pod 的 IAM
- java - JAVA Runnable .JAR File incomplete execution. Eclipse IDE Runs to completion
- python - 空查询集的 Django REST 框架序列化程序数据
- r - 与 mable 分开报告模型
- python - How to drop rows of a pyspark dataframe if they're in another dataframe based on the values from two columns?
- android - How to intercept the back button on an Android Service?