Why is my imported PNG so low quality

I do:

android:background="@drawable/mobile_vforum_bg"

in main.xml to just install BG.

This works, only the image quality is very poor when viewed on an emulator. Its PNG is 320x480 (96 dpi the same in the lower, middle and high folder). When I used Titanium to create my Android app, everything looked great. Now I use eclipse and java and it looks bad.

+3
source share
2 answers

I had this problem when setting a high resolution image as an activity background, and I was able to solve it using the following Java code from the Activity method onCreate().

        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" />

, !!!

+10

res/drawable_hdpi, .

+8

All Articles