How can I load an image from drawable folder?
I've the file name of an image stored in the drawable? how can I open it? I want to know the path?
the file name is String imageFileName = "image.png"
and I want to have the path string something li开发者_运维技巧ke file://drawable/image.png
You can open it using openRawResource(). See more at the documentation.
See this post regarding how to construct a uri to raw resource, though as far as I know it is not recommended.
You can access it through its resource ID. See previous answers such as this one: Select Drawable file path
Here is the code segment showing how you can refer to an image through its resource ID.
Bitmap mBitmap = BitmapFactory.decodeResource(getResources(),
R.drawable.pic1);
int pic_width = mBitmap.width();
int pic_height = mBitmap.height();
See here for more detail
精彩评论