how can I increase the degrade android

3


I want to increase the degrade so that the target is closer to the middle, how can I do it?

<item>
    <shape>
        <gradient
            android:angle="0"
            android:endColor="#E8E8E8"
            android:startColor="#f9f9f9"
            android:type="linear" />
    </shape>
</item>
    
asked by jonatan diaz 06.06.2018 в 14:58
source

3 answers

3

type="linear"

Set the android:angle for a linear type. It must be a multiple of 45 degrees.

<gradient
    android:type="linear"
    android:angle="0"
    android:startColor="#f6ee19"
    android:endColor="#115ede" />

type="radial"

Set the android:gradientRadius for a radial type. Using %p means that it is a percentage of the smallest dimension of the parent.

<gradient
    android:type="radial"
    android:gradientRadius="10%p"
    android:startColor="#f6ee19"
    android:endColor="#115ede" />

More information on this question   link

    
answered by 06.06.2018 / 15:14
source
2

You could play with 2 items instead of one and give it the desired color in the center ..

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:left="50dp">
        <shape android:shape="rectangle">
            <gradient
                android:startColor="#f9f9f9"
                android:centerColor="#f9f9f9"
                android:endColor="@color/colorAccent"
                android:angle="0"
                />
            <size
                android:height="100dp"
                android:width="50dp"/>
        </shape>
    </item>
    <item
        android:right="50dp">
        <shape android:shape="rectangle">
            <gradient
                android:startColor="@color/colorPrimary"
                android:centerColor="#f9f9f9"
                android:endColor="#f9f9f9"
                />
            <size
                android:height="100dp"
                android:width="50dp"/>
        </shape>
    </item>
</layer-list>

Result:

    
answered by 06.06.2018 в 15:34
0
<gradient
        android:angle="0"
        android:endColor="#E8E8E8"
        android:startColor="#f9f9f9"
        android:centreColor="#fafafa" // Color "medio"
        android:centreX="0.7" // Dónde esta el "color medio"
        android:type="linear" />

This will divide the gradient into two parts, one of FAFAFA to F9F9F9 that will occupy 70% of the gradient, and another of F9F9F9 A E8E8E8

link

    
answered by 06.06.2018 в 15:13