Android应用程序加载图像从/可绘制-nodpi /带缩放 [英] Android app loading images from /drawables-nodpi/ with scaling

查看:124
本文介绍了Android应用程序加载图像从/可绘制-nodpi /带缩放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近重建我的Andr​​oid项目的目标从2.2 2.1。

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

在旧的项目,我没有指定目标的SDK(清单中没有包含这样的:安卓的minSdkVersion =8)。运行时,这给了我在控制台中的错误,但一切工作得很好,所以我没有用它愚弄。

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.

新项目现在使用Android的:的minSdkVersion =8在清单

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

但现在我可绘制从/绘制-nodpi /文件夹中加载具有缩放,使它们更小,显著改变所需的视觉效果。

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);

他们仍然在缩放时我宣布在清单中最小的SDK,但不会缩放如果删除该标签。

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

这是怎么回事?我该如何加载它们不进行缩放,同时还宣布了最低SDK?

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

推荐答案

你试试这个?

谷歌

如果你打算读取图像作为   为了将其转换为一个比特流   位图,把你的图片在   RES /生/文件夹而不是,他们在那里   将不被优化。

If you plan on reading an image as a bit stream in order to convert it to a bitmap, put your images in the res/raw/ folder instead, where they will not be optimized.

这篇关于Android应用程序加载图像从/可绘制-nodpi /带缩放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆