0

I have this View in Kotlin:

<View
android:id="@+id/DotView"
android:layout_width="6.5dp"
android:layout_height="6.5dp"
android:layout_marginBottom="10dp"
android:layout_gravity="bottom|center_horizontal"
android:background="@color/colorPrimary"
/>

and I need to round the corners since it is a Dot and I have been investigating and testing how I can do it to round the corners but I just can't find the answer.

How can I solve it?

1 Answers1

1

you have to create a drawable shape xml file and set background property of the view to the drawable file!

res/drawable/circle.xml :

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval">
    <solid android:color="@color/colorPrimary" />
</shape>

res/drawable/rounded.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/colorPrimary"/>
    <corners android:radius="5dp" />
</shape>

and set background to view like this :

<View
android:id="@+id/DotView"
android:layout_width="6.5dp"
android:layout_height="6.5dp"
android:layout_marginBottom="10dp"
android:layout_gravity="bottom|center_horizontal"
android:background="@drawable/rounded"
/>
Vahid Naghash
  • 525
  • 5
  • 11