Aram Kirakosyan
Aram Kirakosyan

Reputation: 11

Create gradient shape in Android

How can I create circle shape with gradient line as a drawable resource, something like this:

enter image description here

Upvotes: 1

Views: 418

Answers (2)

Rajesh
Rajesh

Reputation: 2618

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:innerRadiusRatio="3"
android:shape="ring"
android:thicknessRatio="8"
android:useLevel="false">
<gradient
    android:angle="270"
    android:centerX="50%"
    android:centerY="50%"
    android:endColor="#FF4AA7D0"
    android:gradientRadius="100"
    android:startColor="#FFE66433"
    android:type="linear"
    android:useLevel="false" />
</shape>

Upvotes: 3

Sumit Pathak
Sumit Pathak

Reputation: 529

This is a simple circle as a drawable in Android.

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

   <solid 
       android:color="#666666"/>

   <size 
       android:width="120dp"
        android:height="120dp"/>
</shape>

and you can apply a color filter from Java code (see Drawable class)

Upvotes: -1

Related Questions