下载华电国际,MDPI和LDPI可绘制,并利用它们 [英] Downloading hdpi, mdpi and ldpi drawables and use them
本文介绍了下载华电国际,MDPI和LDPI可绘制,并利用它们的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有可能加载我可绘为华电国际,MDPI和LDPI从给定的URL在运行时使用它们?
Is it possible to load my drawables for hdpi, mdpi and ldpi from given URLs at runtime and use them ?
如果没有,我怎样才能克服气孔密度的问题?
If not, how can I overcome the denisity problem ?
推荐答案
根据屏幕像素密度可以设置图片的URL,
Based on screen density you can set the image URL,
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
switch(metrics.densityDpi){
case DisplayMetrics.DENSITY_LOW:
url = "your_ldpi_url";
break;
case DisplayMetrics.DENSITY_MEDIUM:
url = "your_mdpi_url";
break;
case DisplayMetrics.DENSITY_HIGH:
url = "your_hdpi_url";
break;
}
和您可以获取的图像和使用,
And you can fetch that image and use,
try {
InputStream is = (InputStream) this.fetch(url);
image = Drawable.createFromStream(is,"src");
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
这篇关于下载华电国际,MDPI和LDPI可绘制,并利用它们的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文