user1940676
user1940676

Reputation: 4448

Add a gradient to a layer-list

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.

Upvotes: 5

Views: 2287

Answers (1)

Ginsan
Ginsan

Reputation: 344

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>

Upvotes: 2

Related Questions