Android的/可绘制-nodpi /加载比例 [英] Android /drawable-nodpi/ loading scaled

查看:247
本文介绍了Android的/可绘制-nodpi /加载比例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:结果
  <一href=\"http://stackoverflow.com/questions/3963185/android-app-loading-images-from-drawables-nodpi-with-scaling\">Android从/绘图资源-nodpi /应用程序加载图像使用缩放

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

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:=的minSdkVersion8在清单

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?

推荐答案

有是赋予另一种解释的这里

There is another explanation given here:

如果你不指定&LT;支持的屏幕>或minSdk,那么你的应用程序将在兼容模式下运行,这意味着它给了HVGA(240×320)虚拟屏幕,然后按比例作为一个整体。所以,你的图像将被缩小。

"If you don't specify <supports-screens> or minSdk, then your app will run in compatibility mode, meaning that it's given an HVGA (240x320) "virtual screen", which is then scaled as a whole. So your images will be scaled."

楼主因此运行他们在兼容模式下的应用程序前,图像自动从HVGA扩大到实际的屏幕分辨率;加入的minSdkVersion的图像不再缩小,因此出现了较小的。

The original poster was therefore running their app in this compatibility mode before and the images were automatically scaled up from HVGA to the actual screen resolution; by adding minSdkVersion the images were no longer scaled and therefore appeared smaller.

这篇关于Android的/可绘制-nodpi /加载比例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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