Reputation: 4211
Can I check the type of drawable at runtime whether it is an xml shape/selector/layer-list or jpg/png/gif file?
Upvotes: 1
Views: 1148
Reputation: 6602
You can get type of drawable
with this:
public static String getTypeOfDrawable(int drawableId,Context context) {
Drawable resImg = context.getResources().getDrawable(drawableId);
return resImg.getClass().toString().replace("class android.graphics.drawable.","");
}
You will get result like:
BitmapDrawable
StateListDrawable
Then you if it is BitmapDrawable
its not that hard to get format of file
Upvotes: 1