如何在 Android 上提高图像分辨率

How to improve resolution of image on Android

我已将 3000 x 3000 像素的图像上传到 Android Studios。

当我尝试将图像添加到我的应用程序时,图像看起来不清晰。

这是我的 XML 代码

 <ImageView
   android:layout_width="match_parent"
   android:layout_height="200dip"
   android:scaleType="fitCenter"
   android:contentDescription=""
   android:layout_marginTop="20dip"
   android:layout_marginBottom="28dip"
   android:src="@mipmap/login_logo" />

我认为我的图像对于图像视图来说应该足够大。谁能告诉我如何提高图像的分辨率?

已更新

当我上传图片时,系统自动创建了4个不同版本的图片

我建议在 onCreate() 函数中使用的方法。它使用 BitmapFactory 加载您的图片

Options options = new BitmapFactory.Options();
options.inScaled = false;
Bitmap source = BitmapFactory.decodeResource(a.getResources(), path, options);
ImageView mImg;
mImg = (ImageView) findViewById(R.id.imageView);
mImg.setImageBitmap(source);

问题是您创建的图标集实际上没有 3000 x 3000 像素。检查一下。

应用程序正在使用更合适的尺寸(hdpi、xhdpi 等)。但是您正在手动调整大小。这就是图标在屏幕上不清晰的原因。

当您创建手动图像资源时,这是实际尺寸,具体取决于屏幕尺寸。助手获取原始图像并调整其大小。

ldpi (low) ~120dpi
mdpi (medium) ~160dpi
hdpi (high) ~240dpi
xhdpi (extra-high) ~320dpi
xxhdpi (extra-extra-high) ~480dpi
xxxhdpi (extra-extra-extra-high) ~640dpi

以像素为单位:

36x36 (0.75x) for low-density
48x48 (1.0x baseline) for medium-density
72x72 (1.5x) for high-density
96x96 (2.0x) for extra-high-density
144x144 (3.0x) for extra-extra-high-density
192x192 (4.0x) for extra-extra-extra-high-density

您可以解决这个问题,按照以下说明创建您的自定义图像资产:

LDPI - 0.75x
MDPI - Original size you want to show
HDPI - 1.5x
XHDPI - 2.0x
XXHDPI - 3x
XXXHDPI - 4.0x

https://developer.android.com/guide/practices/screens_support.html

或者你可以使用外部库,比如 Picasso,加载原始图像并进行拟合。动态适配,使用占位符,错误图片等,结果会更专业

https://www.google.es/?ion=1&espv=2#q=picasso%20android

Picasso.with(getActivity())
    .load(new File("path-to-file/file.png"))
    .into(imageView);