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

Ron*_*nie 5 android background

我在做:

android:background="@drawable/mobile_vforum_bg"
Run Code Online (Sandbox Code Playgroud)

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

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

小智 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);
Run Code Online (Sandbox Code Playgroud)

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

<supports-screens android:largeScreens="true"
    android:normalScreens="true" android:smallScreens="true"
    android:anyDensity="true" />
Run Code Online (Sandbox Code Playgroud)

希望这可以帮助!!!


Gri*_*hka 9

尝试将其移动到"res/drawable_hdpi"文件夹,这对我有用.