Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I draw circle through XML Drawable - Android? [duplicate]

I'm trying to draw circle with the help of XML file in android, but circle is not displaying properly. Below code is showing Oval. How can I create circle in XML file.

<shape xmlns:android="http://schemas.android.com/apk/res/android"     android:shape="oval">      <gradient         android:startColor="#FFFF0000"         android:endColor="#80FF00FF"         android:angle="45"/>     <padding android:left="2dp"         android:top="2dp"         android:right="2dp"         android:bottom="2dp" />     <corners android:radius="10dip" />  </shape> 

Any help would be appreciable.

like image 928
VATSHAL Avatar asked Jan 08 '13 06:01

VATSHAL


People also ask

How do I make drawable circles in android?

Usage In Activity Layout Now we can use this shape in the same way we use drawables. Let's set it to android:src of the ImageView. The important thing that you have to notice is that i have given 100dp to both layout_width and layout_height because a circle should have same radius around the area.


1 Answers

no need for the padding or the corners.

here's a sample:

<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval" >     <gradient android:startColor="#FFFF0000" android:endColor="#80FF00FF"         android:angle="270"/> </shape> 

based on :

https://stackoverflow.com/a/10104037/878126

like image 158
android developer Avatar answered Oct 02 '22 09:10

android developer