2

Need to draw the following circle , with the red colour shape using xml.

enter image description here

Is it possible to draw this using xml only?

3 Answers 3

4

You can make circle using the following XML code:

<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval" >
<solid android:color="#c4bfbf"/>
</shape>

You can add the above circle as the background to a view, and on top of that view you could keep another view, which could be center vertical, and it's XML would be:

<shape xmlns:android="http://schemas.android.com/apk/res/android"
       android:shape="rectangle" >
    <solid android:color="#FF0000"  />
    <padding android:bottom="1dp" android:left="10dp" android:right="10dp" android:top="1dp"/>
    <corners
        android:bottomRightRadius="20dp"
        android:bottomLeftRadius="20dp"
        android:topLeftRadius="20dp"
        android:topRightRadius="20dp"/>
</shape>
Sign up to request clarification or add additional context in comments.

1 Comment

0

to draw circle programmatically you can use this way,this worked for me

ShapeDrawable biggerCircle= new ShapeDrawable( new OvalShape());
                biggerCircle.setIntrinsicHeight( 60 );
                biggerCircle.setIntrinsicWidth( 60);
                biggerCircle.setBounds(new Rect(30, 30, 30, 30));
                biggerCircle.getPaint().setColor(Color.parseColor(first));//give any color here
                holder.firstcolor.setBackgroundDrawable(biggerCircle); 

Comments

0

I have create the similar shape where an outer gray circle contains red circle inside. Here is the code:

<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval" >
<solid android:color="#E84F3D" />
<stroke
    android:width="15dp"
    android:color="#BEBEBE" />

</shape>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.