0

I was designing UI in Figma for my Android Studio project. I created rectangle which had several gradients and solid color. How can I create the exact same rectangle in Android Studio? Below is the code in CSS:

background: linear-gradient(180deg, #FCEFFF 0%, rgba(252, 239, 255, 0) 100%), linear-gradient(180deg, #FFFFFF 0%, rgba(252, 239, 255, 0) 70.31%), linear-gradient(180deg, #FFFFFF 0%, rgba(252, 239, 255, 0) 63.02%), #D3AAF4;

I know I should use "solid" and "gradient" tags in XML but it doesn't work as I expect.

Damian
  • 43
  • 4

2 Answers2

0

Try this in an xml layout in your drawable folder:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">

    <gradient android:type="linear"
        android:angle="0"
        android:startColor="#FFF"
        android:endColor="#000"/>

</shape>
0

You can do it like this with custom shape:

<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >

<gradient
    android:angle="45" //your angel
    android:endColor="#87CEEB" //first color
    android:centerColor="#768087" //second color
    android:startColor="#000" //last color
    android:type="linear" />

</shape>
Tamir Abutbul
  • 7,301
  • 7
  • 25
  • 53