Android的 - 确实去codeResource规模为屏幕密度的位图? [英] Android - does decodeResource scale the bitmap for screen density?

查看:100
本文介绍了Android的 - 确实去codeResource规模为屏幕密度的位图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Android的发展中,将

In Android development, will

Bitmap bmpNormal = BitmapFactory.decodeResource(res, R.drawable.normal);

从加载正确的绘图资源密度的文件夹中的位图,或者我需要手动缩放?

load the bitmap from the correct drawables-density folder, or do I need to manually scale it?

我一直没能在模拟器中进行测试,只有在我的手机上显示和我妻子的电话。每产生一个类似规模的位图,即使我有LDPI和MDPI资源。

I haven't been able to test this in the emulator, only on my phone display and my wife's phone. Each one yields a similar sized bitmap, even though I have ldpi and mdpi resources.

推荐答案

其实你应该提供的资源,所有的文件夹
-ldpi
-mdpi
-hdpi
-xhdpi
Android将自动定制和提供的应该是正确sizes.Checkout本的链接。你可以知道如何Android的定制图像在app.You还可以扩展位图和使用它,但它更复杂meathod。

Actually you should provide the resources in all the folders -ldpi -mdpi -hdpi -xhdpi Android will automatically customize it and use it in correct layouts.The resources provided should be of the correct sizes.Checkout this link.You can know how the android customizes the images in an app.You can also scale bitmap and use it but its more complicated meathod.

这篇关于Android的 - 确实去codeResource规模为屏幕密度的位图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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