为什么我进口的PNG质量这么差 [英] Why is my imported PNG such low quality

查看:29
本文介绍了为什么我进口的PNG质量这么差的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在做:

android:background="@drawable/mobile_vforum_bg"

在main.xml文件中设置BG.

in the main.xml file to just set the BG.

它可以工作,只是在模拟器上查看时图像质量很差.它是 320x480 的 PNG(96dpi,在低、中和高文件夹中相同).当我使用 Titanium 构建我的 android 应用程序时,它看起来不错.我现在正在使用 eclipse 和 java,它看起来很糟糕.

It works, just the quality of the image is very poor when viewed on the emulator. Its a PNG at 320x480 (96dpi and the same in the low, med and high folder). When I was using Titanium to build my android app, it looked fine. I am now using eclipse and java and it looks bad.

推荐答案

我在将高分辨率图像设置为 Activity 的背景时遇到了这个问题,我可以通过使用 Activity 的 中的以下 java 代码来解决它onCreate() 方法.

I had this issue while setting a high resolution image as an activity's background and I was able to solve it by using the following java code from the Activity's onCreate() method.

        BitmapFactory.Options myOptions = new BitmapFactory.Options();
        myOptions.inDither = true;
        myOptions.inScaled = false;
        myOptions.inPreferredConfig = Bitmap.Config.ARGB_8888;
        myOptions.inDither = false;
        myOptions.inPurgeable = true;
        Bitmap preparedBitmap = BitmapFactory.decodeResource(yourAppName.getSharedApplication().getResources(),
                R.drawable.yourImage, myOptions);
        Drawable background = new BitmapDrawable(preparedBitmap);
        ((LinearLayout) findViewById(R.id.yourLayoutId))
            .setBackgroundDrawable(background);

如果您使用此代码,也不要从布局 xml 设置背景.如果这不起作用,请尝试在 AndroidManifest.xml 中的应用程序标记之外设置以下行

Also don't set the background from the layout xml if you are using this code. In case this doesn't work try setting the following lines outside the application tag in AndroidManifest.xml

<supports-screens android:largeScreens="true"
    android:normalScreens="true" android:smallScreens="true"
    android:anyDensity="true" />

希望对你有帮助!!!

这篇关于为什么我进口的PNG质量这么差的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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