Add gradient to layer list

How to add a gradient shadow to the right and left of the background?

The next one layer-listadds a black border to the right and left of the background, 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 background.

+4
source share
1 answer

I'm not very sure what you want, gradient background or 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>
+2
source

Source: https://habr.com/ru/post/1539172/


All Articles