material-chip-view
material-chip-view copied to clipboard
vector icon throwing exception
creating and adding chip to the ChipsGroup
for (i in selectedStates){ val chip = Chip(this) chip.text = i chip.setBackgroundColor(Color.parseColor("#2929290D")) chip.chipIcon = ContextCompat.getDrawable(this, R.drawable.ic_close) work_location_chipgroup.addView(chip) chip.setOnClickListener{ work_location_chipgroup.removeView(it) } }
When adding vector icon to the chip, app is crashing with below exception: java.lang.ClassCastException: android.graphics.drawable.VectorDrawable cannot be cast to android.graphics.drawable.BitmapDrawable
You need to convert vector drawable to a bitmap drawable
isn't there a way to use vector icons?
Just wrap your vector drawable into a bitmap drawable