0

I'm trying to set a background using a GradientDrawable. Everything works fine except that the background appears with significant banding. I've tried to enable dithering, but it's not getting any better. Here is a screen shot:

enter image description here

From a coding standpoint, I've done this:

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        /* Deal with gradient banding */
        getWindow().setFormat(PixelFormat.RGBA_8888);

        setContentView(R.layout.activity_main);      
    }

    /* Another attempt to deal with the banding */
    @Override
    public void onAttachedToWindow() {
        super.onAttachedToWindow();
        Window window = getWindow();
        window.setFormat(PixelFormat.RGBA_8888);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

}

And finally, the XML files:

activity_main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:background="@drawable/background"
    tools:context=".MainActivity" >
</RelativeLayout>

drawable/background.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <gradient
        android:angle="90"
        android:startColor="#999"
        android:endColor="#fff"
        android:type="linear"
            android:dither="true"
    />
</shape>

Is there any way to make this look any better? Thank you!

AndroidDev
  • 20,466
  • 42
  • 148
  • 239
  • Maybe this post will help: http://stackoverflow.com/questions/4769885/androiddither-true-does-not-dither-whats-wrong/5581537 –  May 09 '13 at 23:49
  • Thanks. I had seen this and implemented some of the suggestions in it. However, this solution suggests using Photoshop to create a png file, which I don't have access to. There are a few other SO posts on this exact issue. I've been through all of them, but still have the same problem. – AndroidDev May 10 '13 at 00:23
  • I don't use Photoshop either, but http://gimp.org is free. –  May 10 '13 at 00:41

1 Answers1

0

well, here have a link about this issue, hope it could help for you problem: http://www.curious-creature.org/2010/12/08/bitmap-quality-banding-and-dithering/ it give an awesome explanation of this.