【问题标题】:Displaying PNG files in android (images being resized)在android中显示PNG文件(调整大小的图像)
【发布时间】:2011-04-03 20:02:53
【问题描述】:

我将图像拖到 Eclipse 中的 drawable-hdpi 文件夹中,当我将它们加载到程序中时,它们是原始大小的 2/3。 (我的 500x150 .png 被加载为 333x100 .png) 关于我应该如何为 android 创建/加载图像的任何建议?

private Bitmap mGrass;
BitmapFactory.Options options = new BitmapFactory.Options();
options.inPreferredConfig = Bitmap.Config.ARGB_8888;
mGrass = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.grass, options);

canvas.drawBitmap(mGrass, 0, 0, noPaint);

【问题讨论】:

    标签: android png


    【解决方案1】:

    您使用的 AVD[Android Virtual Device] 的 DPI 是多少?如果 DPI 为 160,请把图片转成 mdpi,DPI 大于 240 的手机请放入 hdpi

    【讨论】:

    • 谢谢!我还设置了错误的 AVD,这只会导致进一步的混乱。
    猜你喜欢
    • 2011-07-01
    • 1970-01-01
    • 2017-06-21
    • 2018-07-31
    • 1970-01-01
    • 2016-03-10
    • 1970-01-01
    • 2023-04-03
    • 1970-01-01
    相关资源
    最近更新 更多