material-chip-view icon indicating copy to clipboard operation
material-chip-view copied to clipboard

vector icon throwing exception

Open aayush0208 opened this issue 2 years ago • 3 comments

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

aayush0208 avatar May 20 '22 17:05 aayush0208

You need to convert vector drawable to a bitmap drawable

robertlevonyan avatar May 21 '22 06:05 robertlevonyan

isn't there a way to use vector icons?

aayush0208 avatar May 21 '22 08:05 aayush0208

Just wrap your vector drawable into a bitmap drawable

robertlevonyan avatar May 21 '22 08:05 robertlevonyan