Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add a gradient to a layer-list

Tags:

android

How can I add a gradient shadow from the right and left of the background?

The following layer-list only adds black border from the right and left of the background, and not a gradient border.

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
    <item>
        <shape android:shape="rectangle" >
            <gradient
                android:angle="0"
                android:centerColor="#ffffff"
                android:endColor="#000000"
                android:startColor="#000000" />
        </shape>
    </item>
    <item
        android:left="2dp"
        android:right="2dp">
        <shape android:shape="rectangle" >
            <solid android:color="@color/blue" />
        </shape>
    </item>
</layer-list>

I am trying to add a black shadow from the right and left of the background.

like image 220
user1940676 Avatar asked Nov 02 '22 00:11

user1940676


1 Answers

I'm not very sure what you want, a gradient background or a gradient border? this will give you a gradient black shadow background

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle" >
    <gradient
        android:angle="0"
        android:centerColor="#ffffff"
        android:endColor="#000000"
        android:startColor="#000000" />

</shape>
like image 144
Ginsan Avatar answered Nov 07 '22 10:11

Ginsan