I need to draw three circles in my fragment ,the circles differ in size, I refer this link The result i obtained is this
This is my XML Code : UPDATED
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center" >
<TextView
android:id="@+id/large_volume"
android:layout_width="185dp"
android:layout_height="185dp"
android:background="@drawable/circle"
android:gravity="center"
android:text="My name is NON"
android:textColor="#FFFFFF"
android:textSize="10dp" />
<TextView
android:id="@+id/medium_volume"
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_alignTop="@+id/large_volume"
android:layout_toRightOf="@+id/large_volume"
android:background="@drawable/circle"
android:gravity="center"
android:text="My name is NON"
android:textColor="#FFFFFF"
android:textSize="10dp" />
<TextView
android:id="@+id/TextView02"
android:layout_width="90dp"
android:layout_height="90dp"
android:layout_below="@+id/medium_volume"
android:layout_toRightOf="@+id/large_volume"
android:background="@drawable/circle"
android:gravity="center"
android:layout_marginTop="-3dp"
android:layout_marginLeft="-17dp"
android:text="My name is NON"
android:textColor="#FFFFFF"
android:textSize="10dp" />
</RelativeLayout>
But what i need must be is like this
You can see the circles must stay close together , But when i use XML view i can't achieve this . How can i achieve this , I need onClickListeners
in my circle thats why i use views
Is this can achieve through Canvas drawing , i heard canvas is not view so this will restrict me from giving click listeners ,Correct me if i am wrong
UPDATE :
I fulfill my need through XML approach ,is there any way to achieve this through canvas drawing ,Should i post another question for that ??
Try this code to create dynamically circle with textview
you can set directly backroud or drawable to the textview. you can use drawablepadding ,etc.....
or you can use: android:drawableLeft="@drawable/ic_cab_done_holo_dark"
Try this
Save in drawable
bg_red.xml
Edited Code
ConstraintLayout use for badge count.
Try this
https://stackoverflow.com/a/34685568/2809351