Everyone who tries to use gradients in the images on mobile device comes to the problem: how to make gradients look nicely? The answer is simple – dithering.

I will try to give some tips here about dithering images for Android devices. This is updated version of my previous post about dithering.

First of all you can make dithering in 2 ways:

  1. Dither images from the code or XML on the fly
  2. Pre-dither images in image editor software

Dither images from code

Let’s consider an example: you are trying to make a perfect button for your perfect UI.
You made a superb sketch in (let’s say photoshop) and want to transfer it to your G1 device. In the image editor software the button looks nice:

original button in photoshop

Then try to insert it to the Android Activity layout as ImageView with android:src.

<ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/b1" />

android - no dither

It looks… horrible isn’t it? Let’s try to apply dithering from XML.

Continue reading