Android LinearGradient XML

Unfortunately, the definition of GradientDrawable with XML does not allow more than three colors.

Take a look at the official reference: http://developer.android.com/reference/android/graphics/drawable/GradientDrawable.html.

Example:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <gradient
        android:startColor="#474946"
        android:centerColor="#ff0000"
        android:endColor="#181818"
        android:angle="270"/>
    <corners android:radius="5dp" />
</shape>

So, in your case you would add one more color using android:CenterColor.
But for more than three colors, you’ll even need to do it with Java.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)