Background of 2 colors for layout on android

0

How can I leave a two-color background equally to 50% without gradient effects?

    
asked by César Alejandro M 09.01.2018 в 01:15
source

1 answer

1

Create an archival in the drawable directory with the name you want (it can be a background) and paste the following code

<item>
    <shape>

        <gradient
            android:centerX="0"
            android:endColor="#9A59B5"
            android:startColor="#8D44AD"
            android:type="sweep" />

    </shape>
</item>

Now to the element that you want to apply simply put the background in the following way (in the xml)

android:background="@drawable/fondo"

The file fondo.xml is creating a gradient but type "sweep" which starts from a point and ends at that same point, with the value centerX="0" moves the starting point (from the gradient) to start of the x axis.

If you change the value of 0 or delete it, you will see the original gradient. I hope you serve and greetings

    
answered by 09.01.2018 / 01:44
source