我必须将 res
中的 drawable
显示到 ImageView
中。在这个应用程序中,我出于某些原因使用了 picasso 。
在这种情况下,我需要使用 drawable
的 URI 而不是它的 id 来加载它。
为此,这是我的代码:
uri = Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://"+context.getPackageName()+"/drawable/" + drawableName);
这里使用的drawableName是文件名而不是它们的资源ID。
然后
Picasso.with(context).load(uri).into(imageView);
我确定可绘制的名称是正确的,但 Picasso 似乎不喜欢这个 uri。
最佳答案
如果图像在您的可绘制文件夹中,那么您可以加载它。
Picasso.with(context).load(R.drawable.drawableName).into(imageView);
picasso 会加载它而不需要 Uri。
关于android - Picasso 从其 URI 加载可绘制资源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21158425/