布局背景图片看起来很奇怪

时间:2011-09-15 15:00:46

标签: android android-layout background-image

我在应用程序中添加了一些背景图片到不同的线性布局。
你可以在Eclipse上看到它们看起来都很好。Eclipse
问题是在模拟器或手机上主线性布局的一个搞砸了,有谁知道为什么?

Emulator

这就是我使用的代码:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/back"
    >

背景是真实的图片,而不是代码: The Pic

2 个答案:

答案 0 :(得分:1)

问题可能是您的图像被读入16位(RGB565)位图。请参阅http://www.curious-creature.org/2010/12/08/bitmap-quality-banding-and-dithering/ - 您可能希望从/ res / raw读取图像,并使用BitmapFactory以适当的深度读取它。有关详情,请参阅http://android.nakatome.net/2010/04/bitmap-basics.html。它也可能足以确保使用alpha通道保存.png,这会强制系统将其解释为32位。

答案 1 :(得分:0)

在onCreate()getWindow().setFormat(PixelFormat.RGBA_8888);

中的Activity中尝试此操作