-1
.Oval {
  width: 36px;
  height: 36px;
  margin: 0 10px 0 0;
  padding: 8.6px 11px 9.4px;
  box-shadow: 0 25px 19px -19px rgba(132, 144, 194, 0.53);
  background-image: linear-gradient(216deg, #fdc194 172%, #ff6020 0%);
}

How to convert above css to android drawable XML

2 Answers2

0

Try this..Make a drawable resource file.

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:top="40dp" android:left="20dp"  android:bottom="20dp">
        <shape >
            <solid android:color= "#FFFFff"/>
            <corners android:radius="300dp"/>
        </shape>
    </item>
    <item android:top="20dp"android:gravity="left" android:left="40dp"  android:bottom="40dp" >
        <shape >
            <solid android:color= "#f0f0f0"/>

            <corners android:radius="300dp"/>
        </shape>
    </item>
    <item  android:gravity="left" android:left="60dp"  android:bottom="60dp" >
        <shape >
            <gradient
                android:startColor="#00ffff"
                android:endColor="#0000ff"
                android:angle="90"/>
            <corners android:radius="300dp"/>
            <stroke android:width="1dp"/>
        </shape>
    </item>
</layer-list>

Then set height and width in your view. Please change your required colors.

user14253444
  • 67
  • 1
  • 13
0

Your code looks like you are trying to create a android shape.

You have to create a new layout first. Read this documentation for better understanding. (LinearLayout, RelativeLayout, ConstraintLayout).

https://developer.android.com/guide/topics/ui/declaring-layout https://developer.android.com/studio/write/layout-editor

Read chapter "shape drawable" in this document for better understanding, about how to implement shape drawables:

https://developer.android.com/guide/topics/resources/drawable-resource

After you have created a Layout you have to position a View or ImageView element.

This ImageView gets the android shape you defined as background.

How to define a circle shape in an Android XML drawable file?

Position shape at exact spot on ImageView

Apart from that i would advise you to use dp (density independet pixels) instead of px and sp (scale independent pixel) in the case you use text.

What is the difference between "px", "dip", "dp" and "sp"?

Dorian Feyerer
  • 258
  • 5
  • 14