In my android app I have a simple chip that looks like this.
Is there any way to set the color of the border to make it like this?
UPDATE: I tried to do add the shape but there's an exception during inflating the layout
<android.support.design.chip.Chip
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/chip_with_border"
android:text="my chip" />
drawable/chip_with_border.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="#FFFFFF"/>
<corners android:radius="30dp"/>
<stroke android:width="1dp" android:color="#DDDDDD"/>
</shape>
</item>
</selector>
This causes the exception
android.view.InflateException: Binary XML file line #32: Error inflating class android.support.design.chip.Chip
I found the answer myself. I need to add chipStrokeColor
and chipStrokeWidth
attributes to my chip
<android.support.design.chip.Chip
android:id="@+id/chip"
style="@style/Widget.MaterialComponents.Chip.Filter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:chipStrokeColor="#F0F"
app:chipStrokeWidth="1dp"
android:text="my chip"
app:checkedIcon="@drawable/ic_done_green"
app:chipBackgroundColor="#FFF" />
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