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

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

问题描述

我做的:

android:background="@drawable/mobile_vforum_bg"

在main.xml中的文件到刚才设置的BG。

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

它的工作原理,在仿真器上观看时只是图像的质量非常差。它是一种在PNG分辨率320x480(96DPI在低相同,配有高文件夹)。当我用钛合金打造我的Andr​​oid应用程序,它看起来罚款。我现在使用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.

推荐答案

我有这个问题,同时设定了高分辨率的图像作为活动的背景,我能够通过以下Java code从活动的解决呢的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);

如果您要使用此code也没有设置从布局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天全站免登陆