Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: access a drawable from a specific -dpi folder?

I have two drawable folders: drawable-mdpi and drawable-ldpi

I want to keep this structure (i.e. I don't' want to move my images to /assets), so that Android will automatically pick the appropriate artwork depending on the device density, however, on occasion I need to access the larger drawable version on the smaller device.

Is there a way to access the drawable-ldpi folder from code? I thought the following might be the answer, but it did not work:

    Uri path = Uri.parse("android.resource://com.example.test/res/drawable-ldpi/icon");
    imageview.setImageURI(path); //assume imageview is already initialized etc.

I get a java.io.FileNotFoundException (no such file or directory) warning (it doesn't crash, but it just doesn't load either).

Thanks so much for your help!

like image 260
romamnmlst Avatar asked Aug 28 '12 18:08

romamnmlst


1 Answers

probably not much help but there is Resources.getDrawableForDensity() but this is for API 15 :-(

like image 172
SteelBytes Avatar answered Oct 04 '22 06:10

SteelBytes