I'm trying to apply a linear gradient to my ListView. This is the content of my drawable xml:
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <gradient android:startColor="#3A3C39" android:endColor="#181818" android:angle="270" /> <corners android:radius="0dp" /> </shape>
So I apply it to my ListView with:
android:background="@drawable/shape_background_grey"
It works but it looks very "banded" on emulator and on a real device too.
Is there any way to reduce this "behaviour"?
attributes: android:angle Integer. The angle for the gradient, in degrees. 0 is left to right, 90 is bottom to top. It must be a multiple of 45.
As Romain Guy suggests:
listView.getBackground().setDither(true);
solves my problem
If this is not enough especially for AMOLED and/or hdpi devices try this:
@Override public void onAttachedToWindow() { super.onAttachedToWindow(); Window window = getWindow(); window.setFormat(PixelFormat.RGBA_8888); }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With