I want to print sizes of all drawables at run-time. So if I am on hdpi
device then I can print the size of hdpi
drawables but how to get access to, lets say mdpi
and xhdpi
as well? I can get access to all drawables resource ids with following code:
final Class<R.drawable> c = R.drawable.class;
final Field[] fields = c.getDeclaredFields();
for (int i = 0, max = fields.length; i < max; i++) {
final int resourceId;
try {
resourceId = fields[i].getInt(drawableResources);
} catch (Exception e) {
continue;
}
/* make use of resourceId for accessing Drawables here */
}