I generally use a 'proxy' XML drawable to add dithering.
Suppose your drawable above was named grad.xml, I'd then create
something like:
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/grad"
android:dither="true" />
and name it grad_proxy.xml. Then use @drawable/grad_proxy in place of
@drawable/grad.
You shouldn't need to use any extra Java code, the XML above should
work as is.
On Jul 23, 12:59 pm, manigault <[email protected]> wrote:
> Hi all,
> In my activity i have simple grey gradient
> <?xml version="1.0" encoding="utf-8"?>
> <shape xmlns:android="http://schemas.android.com/apk/res/android"
> android:shape="rectangle">
> <gradient android:startColor="#323232" android:endColor="#909090"
> android:angle="270" />
> </shape>
>
> and i use as background of some view. The problem is that the gradient
> looks pretty banding. After searching i found some solutions and posts
> about this problem but none of them works the way i
> want.http://stackoverflow.com/questions/2928101/android-using-linear-gradi...http://stackoverflow.com/questions/2791045/is-it-possible-to-dither-a...http://stuffthathappens.com/blog/2010/06/04/android-color-banding/http://android.amberfog.com/?p=247
>
> The only i could smooth the gradient on htc tatoo was to set
> getWindow().addFlags(WindowManager.LayoutParams.FLAG_DITHER) which
> dithers the whole window not only the gradient which is not what i
> want. Setting android:dither="true" and calling from Java
> GradientDrawable.setDither(true) has no effect. On nexus one
> getWindow().setFormat(PixelFormat.RGBA_8888) but on devices that don't
> have 8-bits per color i have to set FLAG_DITHER so what is the correct
> way to smooth gradient.
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en