我正在 android 上编写应用程序。我正在从服务器下载图像并尝试使用 setBackgroundDrawable 将其设置为 ImageView 背景。
Drawable drawable = Drawable.createFromPath(path)
imageView.setBackgroundDrawable(drawable);
它可以工作,但图像已调整大小(变小)。有没有人知道如何在不改变其大小的情况下设置 ImageView 背景?
编辑: 我通过使用解决了这个问题:
File imgFile = new File(path);
Bitmap myBitmap = BitmapFactory.decodeFile(imgFile.getAbsolutePath());
imageView.setImageBitmap(myBitmap);
最佳答案
imageView.setScaleType (ImageView.ScaleType.MATRIX)
将图像缩放类型设置为矩阵,绘制时将使用图像矩阵进行缩放。
关于android - 如何防止在 Android 中调整图像大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9513510/