是否有可能采用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,例如 https://m.xsw88.com/allimgs/daicuo/20230903/5700.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. https://m.xsw88.com/allimgs/daicuo/20230903/5700.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;
}