views:

30

answers:

1

I recently rebuilt my Android project to target 2.2 from 2.1.

In the old project, I did not specify a target SDK (the manifest did not contain something like: android:minSdkVersion="8"). This gave me an error in the console when running, but everything worked fine so I didn't fool with it.

The new project now uses android:minSdkVersion="8" in the manifest.

But now my drawables from the /drawable-nodpi/ folder are loading with scaling, making them much smaller and significantly changing the desired visuals.

If I cut out the tag from my manifest, they load properly without scaling.

Even when loading my images like so:

        BitmapFactory.Options opts = new BitmapFactory.Options();
        opts.inScaled = false;   
        Bitmap bm = BitmapFactory.decodeResource(_resources, resId, opts);

They are still scaled when I declare the minimum SDK in the manifest, but not scaled if I remove that tag.

Why is this happening? How can I load them without scaling while still declaring the minimum SDK?

A: 

When you set minsdkversion you are telling Android that the app can work from API level 8, which is Android 2.2. Previously since you didnt specify that, Android knew how to handle assets, but now with minsdkversion line in manifest you are providing guidelines.

Read up on how all assets and assets hierarchy is implemented in Android here and here. This may be not the quick fix answer you want, but it will help you understand Android platform better.

omermuhammed
Thank you for the response -- I've spent significant time reading both of those pages already trying to resolve this. It even specifically mentions placing files in the /drawable-nodpi/ folder, which I have done, to avoid scaling. They are still being scaled. Why would android:minSdkVersion="8" cause it to decide that images in the nodpi folder should be scaled, even when all documentation says they will not be?
jjj
One thing I can think of is you have same assets in hdpi/mdpi/ldpi folder and also in nodpi folder. Based on how Android handles the folder hierarchy it may do that.
omermuhammed
All of my graphic assets are in the nodpi folder exclusively. I'm making a game that programatically draws the bitmaps on a surface, and don't have any situation in which they should be scaled for DPI. I've not been able to find any solution to this... Am I okay just leaving the minSdkVersion tag out of my manifest, or will I run into problems when I publish?
jjj
You should be ok, just test it with different versions of Android.
omermuhammed