如何从 android studio 的单个可绘制文件夹中检测多分辨率图像

How to detect multiple resolutions images from a single drawable folder at android studio

我正在使用 Android Studio 开发一个 Android 应用程序,我引用了这个 link使用不同的图像资源,但我未能获得输出。

我需要的是 "I have 480x640_240dpi, 480x800_240dpi, 480x854_240dpi, 600x1024_240dpi in my drawable-hdpi folder",但是 运行 应用程序时图像正在拉伸。

如何将正确分辨率的图像检测到对应的设备。 并且还帮助我如何将图像添加到平板电脑(这也只能在横向模式下,在我的应用程序中,平板电脑无法按要求在纵向模式下工作)。 提前致谢。

根据分辨率放置所有图像。 即

  • res/drawable-mdpi/graphic.png // bitmap for medium-density
    res/drawable-hdpi/graphic.png // bitmap for high-density
    res/drawable-xhdpi/graphic.png // bitmap for
    extra-high-density res/drawable-xxhdpi/graphic.png // bitmap
    for extra-extra-high-density

了解更多详情 http://developer.android.com/guide/practices/screens_support.html

使用资源目录限定符可以针对特定分辨率。例如,您可以在 hdpi 屏幕上为 480px x 800px 图像创建文件夹 drawable-w320dp-h533dp-hdpi

编辑:由于您可能正在使用 Android Studio,因此您可以在创建新资源目录时在对话框中定义限定符。