为什么我的进口PNG质量如此之低

时间:2011-05-04 20:33:39

标签: android background

我在做:

android:background="@drawable/mobile_vforum_bg"

在main.xml文件中只设置BG。

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

2 个答案:

答案 0 :(得分:11)

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

        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

中的应用程序标记之外设置以下行
<supports-screens android:largeScreens="true"
    android:normalScreens="true" android:smallScreens="true"
    android:anyDensity="true" />

希望这有助于!!!

答案 1 :(得分:9)

尝试将其移至“res / drawable_hdpi”文件夹,这对我有用。

相关问题