Search code examples
androidgradientradial-gradients

Android gradient NEVER works (always banding)


I tried to add a (radial) gradient as background (in Android 4.0), either as background image or programmatically but none of them never works. I can only test it in emulator, but I guess it's the same on a 4.0 device.

These solutions don't work:

I guess I tried some more things but maybe someone has an idea how to build a working gradient as background?

My current code looks like this:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".SplashScreen">

    <ImageView
        android:id="@+id/imageViewLogo"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:contentDescription="@string/desc_string"
        android:scaleType="centerCrop"
        android:src="@drawable/background_image" />

</RelativeLayout>

and background_image.xml

<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/background_image"
    android:antialias="true"
    android:dither="true"
    android:src="@drawable/bg_portrait" />

Solution

  • Obviously it's just the emulator. On a real device it looks good.