Víctor Martín
Víctor Martín

Reputation: 3450

How I can put this gradient in a XML resource?

this is a simple question, but I don't know how to do it.

The gradient has two parts, the result is this.

Gradient

The code generated is the next, but I don't know how to put inside an only one XML to use as a background.

<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
<gradient 
android:type="linear"
android:centerX="30%" 
android:startColor="#00ffffff" 
android:centerColor="#FFffffff" 
android:endColor="#00ffffff" 
android:angle="0"/>
</shape>

-------------------------------------------------
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
<gradient 
android:type="radial"
android:centerX="50%" 
android:centerY="50%" 
android:startColor="#00ffffff" 
android:centerColor="#FFffffff" 
android:endColor="#00ffffff" 
android:gradientRadius="30"/>
</shape>

Thanks

EDIT:

CODE

<?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:type="linear"
                android:centerX="30%"
                android:startColor="#00ffffff"
                android:centerColor="#FFffffff"
                android:endColor="#00ffffff"
                android:angle="0"/>
        </shape>
    </item>

    <item>
        <shape android:shape="rectangle" >
            <gradient
                android:type="radial"
                android:centerX="50%"
                android:centerY="50%"
                android:startColor="#00ffffff"
                android:centerColor="#FFffffff"
                android:endColor="#00ffffff"
                android:gradientRadius="30"/>
        </shape>
    </item>
</layer-list>

RESULT

Result

Upvotes: 0

Views: 702

Answers (1)

snachmsm
snachmsm

Reputation: 19253

<layer-list
    xmlns:android="http://schemas.android.com/apk/res/android" >
    <item>
        <shape android:shape="rectangle" >
            <gradient 
                android:type="linear"
                android:centerX="30%" 
                android:startColor="#00ffffff" 
                android:centerColor="#FFffffff" 
                android:endColor="#00ffffff" 
                android:angle="0"/>
        </shape>
    </item>
    <item>
        <shape android:shape="rectangle" >
            <gradient 
                android:type="radial"
                android:centerX="50%" 
                android:centerY="50%" 
                android:startColor="#00ffffff" 
                android:centerColor="#FFffffff" 
                android:endColor="#00ffffff" 
                android:gradientRadius="30"/>
        </shape>
    </item>
</layer-list>

more about Layer List (and other) here

Upvotes: 2

Related Questions