Change Chip Widget style programmatically not working - Android

后端 未结 3 1729
说谎
说谎 2020-12-02 01:53

I\'m doing a list with Chips. I want this chips can be selected, so, taking a look to https://material.io/develop/android/components/chip/ I see I can have a \"Choice Chip\"

3条回答
  •  栀梦
    栀梦 (楼主)
    2020-12-02 02:27

    In order to set the chip style in code you can try the following:

    val chip = Chip(context)
    val drawable = ChipDrawable.createFromAttributes(context, null, 0, R.style.Widget_MaterialComponents_Chip_Choice)
    chip.setChipDrawable(drawable)
    

提交回复
热议问题