在设备中的图像中设置适当的dpi

时间:2013-11-24 03:34:15

标签: android

我正在开发app获取一个XML。我解析这个XML。我得到像logoldpi,logomdpi,logohdpi,logoxh dpi的图像名称。现在我需要根据设备dpi设置这些图像。我已根据设备dpi设置这些图像但是如果我的设备是hdpi并且我得到logohdpi null然后我需要设置logomdpi如果它是null然后logoldpi如何解决这个问题?

请帮忙。

提前致谢。

2 个答案:

答案 0 :(得分:1)

为不同的分辨率制作不同的可绘制文件夹。 例如ldpi - drawable-ldpi    hdpi - drawable-hdpi    mdpi - drawable-mdpi    xhdpi - drawable-xhdpi

并将图像相应地放在这些文件夹中,android os将相应地选择它们。

答案 1 :(得分:0)

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

*hdpi image folder maintain images for the Android Broad Screen set or Android Phones with the Higher resolution.

*ldpi image folder for Lower images quality which supports by the earlier sets of the android

*mdpi image folder for medium images support

*xhdpi image folder for devices with maximum resolution.

xxhdpi image folder for devices extra large devices(Like Google Nexus 10 need to add a 144*144px icon in the drawable-xxhdpi or drawable-480dpi folder.)

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