I'm generating Material.Chip
views in my fragment. I'd like to configure their appearance, but I'd like to do so using a style. I've read online that I could use a ContextThemeWrapper
like so:
Chip chip = new Chip(new ContextThemeWrapper(getContext(), R.style.ChipToolbarUnchecked));
chip.setId(View.generateViewId());
chip.setCheckable(true);
chipGroup.addView(chip);
with the following style in res/values/themes.xml
:
<style name="ChipToolbarUnchecked">
<item name="checkedIconVisible">false</item>
<item name="chipBackgroundColor">@color/background_color_chip_state_list_toolbar</item>
</style>
but that didn't work. The check icon remained visible, and the colors were default. To make sure that the style was actually getting applied, I tried different attributes, and android:textSize
worked fine. I also tried applying my style to a chip statically defined in a layout file, and it worked as expected - the check icon was hidden, and the colors were correct. Looking for possible solutions online, I tried writing
Chip(new ContextThemeWrapper(getContext(), R.style.ChipToolbarUnchecked), null, 0)
instead, but that didn't fix the problem.
What am I missing?