Android的 - 检索设备,相应的绘制文件夹作为一个字符串 [英] Android - retrieve the device-appropriate drawable folder as a string
本文介绍了Android的 - 检索设备,相应的绘制文件夹作为一个字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有可能采用Android获取正确绘制的文件夹名称为一个字符串?
Is it possible to retrieve the correct drawable folder name as a String using Android?
例如,我想,作为一个字符串:
For example, I would like, as a string:
String drawableFolder = someFunction.getFolder();
Log.i("", drawableFolder);
....输出:
....to output:
XXDPI
使用情况:我从远程URL下载图像,并想一个机制,以检索设备,适当的图像。它发生在我,我可以prePEND使用正确的名称的URL,例如 http://static.images.server.com/XXDPI_image.png
Usage case: I'm downloading images from a remote URL and would like a mechanism to retrieve a device-appropriate image. It occurred to me I could prepend the URL with the correct name, e.g. http://static.images.server.com/XXDPI_image.png
推荐答案
您可以打通器件密度以下
You can get the following through device density
int density= getResources().getDisplayMetrics().densityDpi;
switch(density)
{
case DisplayMetrics.DENSITY_LOW:
Log.d(TAG, "LDPI");
break;
case DisplayMetrics.DENSITY_MEDIUM:
Log.d(TAG, "MDPI");
break;
case DisplayMetrics.DENSITY_HIGH:
Log.d(TAG, "HDPI");
break;
case DisplayMetrics.DENSITY_XHIGH:
Log.d(TAG, "XHDPI");
break;
}
这篇关于Android的 - 检索设备,相应的绘制文件夹作为一个字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文