In an Android app, I need to create clickable chips within a Chat bubble (see image below).
I have added a ChipGroup below the TextView but since the text for chips is too long, it is getting clipped.
Any idea how I can have a multiline text in Chip or any workaround for this?
Unfortunately chips does not support multiline text. Below is the reference from Chip.java
@Override
public void setSingleLine(boolean singleLine) {
if (!singleLine) {
throw new UnsupportedOperationException("Chip does not support multi-line text");
}
super.setSingleLine(singleLine);
}
@Override
public void setLines(int lines) {
if (lines > 1) {
throw new UnsupportedOperationException("Chip does not support multi-line text");
}
super.setLines(lines);
}
@Override
public void setMinLines(int minLines) {
if (minLines > 1) {
throw new UnsupportedOperationException("Chip does not support multi-line text");
}
super.setMinLines(minLines);
}
@Override
public void setMaxLines(int maxLines) {
if (maxLines > 1) {
throw new UnsupportedOperationException("Chip does not support multi-line text");
}
super.setMaxLines(maxLines);
}
However we trying to implement the similar behaviour with AppCompatCheckBox
as chip inherits the same class.
You can use chip class for detail reference :https://github.com/material-components/material-components-android/blob/master/lib/java/com/google/android/material/chip/Chip.java
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With