Getting chipBackground color from a chip

43 Views Asked by At

I would like to get the color of my Chip but this way I can't because what I get is ColorStateList.

 colors.children.forEach {
                val chip = it as Chip
                chip.setOnCheckedChangeListener { buttonView, isChecked ->
                    handleSelection(chip)
                }
            }
//...
  private fun handleSelection(chip : Chip) {
    val intColor = chip.chipBackgroundColor?.defaultColor
    val hexColor = "#" + Integer.toHexString(intColor!!).substring(2)

    Log.d("BottomSheetFragment", hexColor)
}

How can I get the current color of my chip ?

0

There are 0 best solutions below