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

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.

This question is related to android android-layout android-xml

The answer is


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


Examples related to android

Under what circumstances can I call findViewById with an Options Menu / Action Bar item? How to implement a simple scenario the OO way My eclipse won't open, i download the bundle pack it keeps saying error log getting " (1) no such column: _id10 " error java doesn't run if structure inside of onclick listener Cannot retrieve string(s) from preferences (settings) strange error in my Animation Drawable how to put image in a bundle and pass it to another activity FragmentActivity to Fragment A failure occurred while executing com.android.build.gradle.internal.tasks

Examples related to android-layout

How to check if a key exists in Json Object and get its value How to center the elements in ConstraintLayout Android - how to make a scrollable constraintlayout? Add ripple effect to my button with button background color? This view is not constrained vertically. At runtime it will jump to the left unless you add a vertical constraint Is it possible to put a ConstraintLayout inside a ScrollView? Differences between ConstraintLayout and RelativeLayout How to remove title bar from the android activity? How to have EditText with border in Android Lollipop Android: ScrollView vs NestedScrollView

Examples related to android-xml

Add a background image to shape in XML Android Custom designing EditText How can I draw circle through XML Drawable - Android? dpi value of default "large", "medium" and "small" text views android Android : difference between invisible and gone? error: Error parsing XML: not well-formed (invalid token) ...? Difference between "@id/" and "@+id/" in Android How can you get the Manifest Version number from the App's (Layout) XML variables? Android button with different background colors Vertical line using XML drawable