No, Android does not allow subfolders under /res/drawable
: Can the Android dropdown directory contain subdirectories?
However, you can add all image files to /drawable
, and then access them programmatically with:
int drawableID = context.getResources().getIdentifier("drawableName", "drawable", getPackageName()); iv.setImageResource(drawableID);
Where drawableName
is the name of the file to be extracted, i.e. myimage
if the image file is myimage.jpg
.
In the above code, an image resource with the identifier R.drawable.drawableName
will be created.
source share