我在做:
android:background="@drawable/mobile_vforum_bg"
在 main.xml 文件中设置 BG。
它可以工作,只是在模拟器上查看时图像质量非常差。它是 320x480 的 PNG(96dpi,低、中和高文件夹中相同)。当我使用 Titanium 构建我的 Android 应用程序时,它看起来不错。我现在使用 eclipse 和 java,看起来很糟糕。
我在将高分辨率图像设置为活动背景时遇到了这个问题,我能够通过使用活动中的以下 java 代码来解决它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 中的应用程序标记之外设置以下行
<supports-screens android:largeScreens="true"
android:normalScreens="true" android:smallScreens="true"
android:anyDensity="true" />
希望这可以帮助!!!
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)