Android的 - 参考资源绘制一个网址 [英] Android - Reference resource drawable as a URL

查看:126
本文介绍了Android的 - 参考资源绘制一个网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用在我的Andr​​oid应用程序从网上下载图片,并显示一个占位符的动画,而图像正在下载的API(RemoteImageView,点火包的这里

I'm using an API in my Android app that downloads images from the web and shows a placeholder animation while the images are downloading (RemoteImageView, part of the Ignition package here.

在应用中的一些问题,我需要从本地资源可绘制显示图片,而不是从网上下载。

At some points in the app, I need to show images from the local resource drawables and not downloaded from the web.

是否有可能使用URL访问本地资源可绘制?

Is it possible to access the local resource drawables using a URL ?

推荐答案

本地图片资源没有URL,但它们有URI。所以,如果你在绘制有图像,可以从资源ID URI解析。

Local image resources do not have urls, they have URIs. So if you have image in drawable, you can parse them from resource id to URI.

Uri uri=Uri.parse("R.drawable.image");

不过,如果你也可以把你的图片在包的资源文件夹,并使用他们的URL访问它们。图像文件的URL将是文件:///android_asset/image.png
您可以使用选项任。

However, if you can also put your images in asset folder of the package and access them using their URL. The URL of the image files would be "file:///android_asset/image.png" You can use either of the option.

这篇关于Android的 - 参考资源绘制一个网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆