Android 上 ImageView 中的矢量可绘制缩放

问题描述 投票:0回答:1

我得到了一种数据的示意图,该数据存储为矢量绘图,是从 SVG 格式的原始图像获得的。我需要放大和缩小它,但是在更改

scaleX
scaleY
参数后,图像变得模糊。你能帮我通过重新绘制来改变图像的大小吗,以使文本和其他元素看起来不像过度缩放的 PNG。

我的代码:


imageView = findViewById<ImageView>(R.id.image_view).apply {
    scaleX = 3f
    scaleY = 3f
    invalidate()
}
android kotlin android-studio imageview android-vectordrawable
1个回答
0
投票

试试这个代码

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

}

© www.soinside.com 2019 - 2024. All rights reserved.