Skip to content Skip to sidebar Skip to footer

Get Drawable For Different Screen Density At Runtime

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?

Solution 1:

Ok I found it, Basically you explicitly ask for a particular density drawable like this:

Drawable drawable = resources.getDrawableForDensity(id, DisplayMetrics.DENSITY_XHIGH);

or preferably this version

Drawable drawable = resources.getDrawableForDensity(id, DisplayMetrics.DENSITY_XHIGH, theme);

Post a Comment for "Get Drawable For Different Screen Density At Runtime"