Vector drawable scaling in ImageView on Android

47 views Asked by At

I got a kind of schematic presentation of data that is stored as a vector drawable, obtained from an original image in SVG format. I need to zoom it in and out, but after changing scaleX and scaleY parameters the image gets blurry. Can you help me change image's size with a kind of redrawing after that to make text and other elements look not like overzoomed PNG.

My code:


imageView = findViewById<ImageView>(R.id.image_view).apply {
    scaleX = 3f
    scaleY = 3f
    invalidate()
}
1

There are 1 answers

0
Aia Ashraf On

Try this code

imageView = findViewById<ImageView>(R.id.image_view).apply {
scaleX = 3f
scaleY = 3f
invalidate()
setImageBitmap(Bitmap.createScaledBitmap(bitmap, width * scaleX, height * scaleY, true))

}