Hmm, interesting... Just had a chance to try this out on 1.5. If I move my bitmaps into a drawable-nodpi directory then the application compiles and executes, but I don't see the images. Inspection with the debugger (plus logging just to make sure) indicates that the bitmaps, when loaded from "nodpi" always have a width and height of 1px.
Move them back to the basic drawable directory and it all works perfectly again. Shame, looks like it was *almost* implemented :) Tom. 2009/9/17 Romain Guy <romain...@google.com> > > Give it a try, 1.5 already had all the scaling code based on display's > density. I don't know about nodpi specifically but it's worth the try. > > On Thu, Sep 17, 2009 at 11:46 AM, Tom Gibara <m...@tomgibara.com> wrote: > > Duh, I misread the docs for the inScaled flag. Thanks for pointing that > out. > > The drawable-nodpi/ sounds perfect, but I'm guessing I can't use that and > > remain compatible with API 3, since I don't see "nodpi" listed the > > documentation for resources in 1.5. > > Tom. > > > > 2009/9/17 Romain Guy <romain...@google.com> > >> > >> > private Bitmap loadBitmap(int resId) { BitmapFactory.Options options = > >> > new > >> > BitmapFactory.Options(); options.inTargetDensity = 1; > options.inDensity > >> > = 1; > >> > return BitmapFactory.decodeResource(context.getResources(), resId, > >> > options); > >> > } > >> > >> That's the wrong way to do it. You're assigning your bitmap a density > >> of 1dpi, which can have bad consequences. There's a much simpler way > >> to do it: just set options.inScaled = false. > >> > >> But the right way to do it really is to place the assets in the right > >> directory: > >> drawable-ldpi/ for 120dpi displays > >> drawable-mdpi/ for 160dpi displays > >> drawable-hdpi/ for 240dpi displays > >> > >> and in your case: > >> drawable-nodpi/ for assets that should not be scaled. > >> > >> > I have two related queries: > >> > Is there a simpler way of doing this? > >> > Is there a way to support android:minSdkVersion="3" without jumping > >> > through > >> > the hoop of creating two implementations (for API 3 and API 4) of an > >> > "image > >> > loading" interface and selecting one at runtime? > >> > Tom. > >> > > > >> > > >> > >> > >> > >> -- > >> Romain Guy > >> Android framework engineer > >> romain...@android.com > >> > >> Note: please don't send private questions to me, as I don't have time > >> to provide private support. All such questions should be posted on > >> public forums, where I and others can see and answer them > >> > >> > > > > > > > > > > > > > -- > Romain Guy > Android framework engineer > romain...@android.com > > Note: please don't send private questions to me, as I don't have time > to provide private support. All such questions should be posted on > public forums, where I and others can see and answer them > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---