syedowaisali / crystal-range-seekbar

537 stars 164 forks source link

Vector drawable support #22

Closed felix2ch closed 6 years ago

felix2ch commented 7 years ago

Set thumb to a vector drawable, seekbar disappeared. Should be a feature or a bug?

syedowaisali commented 6 years ago

noted and add this feature to upcoming version.

yaroslav-android commented 5 years ago

Workaround for vector drawable support (works for both views range and single):

override fun getLeftDrawable(typedArray: TypedArray?): Drawable {
        val drawable = ContextCompat.getDrawable(context, R.drawable.vector)

        val bitmap = Bitmap.createBitmap(
            drawable!!.intrinsicWidth,
            drawable.intrinsicHeight, Bitmap.Config.ARGB_8888
        )
        val canvas = Canvas(bitmap)
        drawable.setBounds(0, 0, canvas.width, canvas.height)
        drawable.draw(canvas)

        return BitmapDrawable(resources, bitmap)
    }