drawable-hdpi,drawable-ldpi,drawable-mdpi,drawable-xhdpi和drawable-xxhdpi是什么意思

sha*_*aby 12 android

我真的很困惑res下的drawable-hdpi,drawable-ldpi,drawable-mdpi,drawable-xhdpi和android drawable类型的drawable-xxhdpi有什么意义,以及如何决定使用哪一个sholud?

Shy*_*dda 12

默认情况下,Android为图像提供三个文件夹,其背后不同的分辨率原因是应用程序将要执行的Android设备的使用或分辨率.

  • hdpi图像文件夹维护Android Broad Screen集或具有更高分辨率的Android手机的图像.

  • ldpi图像文件夹用于较低图像质量,由早期的android设置支持

  • 支持中画面的mdpi图像文件夹

  • xhdpi 图像文件夹,用于具有大分辨率的设备.

  • xxhdpi图像文件夹,用于设备超大设备/最大分辨率(如Google Nexus 10需要在drawable-xxhdpi或drawable-480dpi文件夹中添加144*144px图标.)

Android OS通过检查兼容设备及其分辨率来选择自己的图像.


kri*_*hna 9

ldpi    Resources for low-density (ldpi) screens (~120dpi).
mdpi    Resources for medium-density (mdpi) screens (~160dpi). (This is the baseline density.)
hdpi    Resources for high-density (hdpi) screens (~240dpi).
xhdpi   Resources for extra high-density (xhdpi) screens (~320dpi).
nodpi   Resources for all densities. These are density-independent resources. The system does not scale resources tagged with this qualifier, regardless of the current screen's density.
tvdpi   Resources for screens somewhere between mdpi and hdpi; approximately 213dpi. This is not considered a "primary" density group. It is mostly intended for televisions and most apps shouldn't need it—providing mdpi and hdpi resources is sufficient for most apps and the system will scale them as appropriate. If you find it necessary to provide tvdpi resources, you should size them at a factor of 1.33*mdpi. For example, a 100px x 100px image for mdpi screens should be 133px x 133px for tvdpi.
Run Code Online (Sandbox Code Playgroud)

因此,当你创建drawable-hdpi, drawable-ldpi, drawable-mdpi, drawable-xhdpi and drawable-xxhdpi手机时,根据其像素密度适当地获取资源.如果没有指定任何内容,它将从中获取资源drawable.有关详细信息,请点击此处