Need to draw the following circle , with the red colour shape using xml.
Is it possible to draw this using xml only?
Need to draw the following circle , with the red colour shape using xml.
Is it possible to draw this using xml only?
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>
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);
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>