0

在开发 Android 应用程序时,我看到资产中显示的所有图像都是像素化的。

我正在使用这 2 行来显示它们:

Drawable imageDrawable = Drawable.createFromStream("my_logo.png", null);
imageView.setBackground(imageDrawable);

图像的尺寸为:128/128 或 256/256,并显示在方形 ImageView 中。

有人想保持我的图像质量吗?

4

2 回答 2

0

更改图像的尺寸会降低质量。你可以做几件事

  1. 请改用向量。矢量可以无限放大和缩小而不会损失质量。
  2. 使用ImageView与图像大小相同或更小的高度和宽度,并保持纵横比。
于 2018-02-27T15:21:08.043 回答
0

void setImageDrawable (Drawable drawable)
将可绘制对象设置为 ImageView 的内容。

要将drawable设置为ImageView从java,您需要使用setImageDrawable (Drawable drawable)方法。

您正在将可绘制对象设置为 imageView 的背景,您的代码应该是,
Drawable imageDrawable = Drawable.createFromStream("my_logo.png", null); imageView.setImageDrawable(imageDrawable);

于 2018-02-27T16:07:04.520 回答