0

I added some background pictures to different linear layouts in my application.
as you can see on Eclipse they all look fine.Eclipse
The problem is that on an emulator or a phone the one for the main linear layout gets messed up, does anyone know why?

Emulator

That's the code I used:

<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 background is a real picture, not code: The Pic

eladrich
  • 745
  • 1
  • 5
  • 15
  • post some code so that we can help you. – Yashwanth Kumar Sep 15 '11 at 15:03
  • possible duplicate of [Android: Using linear gradient as background looks banded](http://stackoverflow.com/questions/2928101/android-using-linear-gradient-as-background-looks-banded) – Yoni Samlan Sep 15 '11 at 15:04
  • 1
    Particularly, setting the window to RGBA_888 should look the best (and should be the default on Android 2.3+ devices anyways). Also see http://stuffthathappens.com/blog/2010/06/04/android-color-banding/ – Yoni Samlan Sep 15 '11 at 15:05
  • @Yashwanth Kumar I posted the code, don't think it will help you. – eladrich Sep 15 '11 at 15:09
  • @Yoni Samlan I don't think that's my problem, as I just noted I that used a picture. – eladrich Sep 15 '11 at 15:12

2 Answers2

1

The problem may be that your image is being read into a 16-bit (RGB565) bitmap. See http://www.curious-creature.org/2010/12/08/bitmap-quality-banding-and-dithering/ -- you may want to read the image from /res/raw and use a BitmapFactory to read it in at the proper depth. Also see http://android.nakatome.net/2010/04/bitmap-basics.html for more on that. It also might be enough to make sure to save your .png with an alpha channel, which would force the system to interpret it as 32-bit.

Yoni Samlan
  • 36,907
  • 5
  • 58
  • 62
0

Try this in Activity in onCreate() getWindow().setFormat(PixelFormat.RGBA_8888);

Mikooos
  • 5,099
  • 4
  • 29
  • 44