1

I want to create special view for my app. It is vertical dotted line and two half circles on a top and bottom. Is there any way how to create this as single shape drawable? I made dotted line, but I cant make half circle.

It should looks like this.

enter image description here

Dotted vertical line:

<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android" android:fromDegrees="90" android:toDegrees="90">
    <shape
            android:shape="line">
        <stroke
                android:color="#777777"
                android:dashWidth="7dp"
                android:dashGap="5dp"
                android:width="2dp"/>
    </shape>
</rotate>

I have found as someone tried to make half circle, but its big. I need only small circle. And it is not even circle.

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <corners
            android:bottomLeftRadius="100000dp"
            android:topLeftRadius="0dp"
            android:bottomRightRadius="100000dp"
            android:topRightRadius="0dp" />

    <solid android:color="#777777" />
</shape>
Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
martin1337
  • 2,384
  • 6
  • 38
  • 85

2 Answers2

6

Create half_circle.xml file under drawable with this line

<?xml version="1.0" encoding="utf-8"?>
<shape
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <solid android:color="#8C9AEE"/>
    <size
    android:width="120dp"
    android:height="60dp"/>
   <corners
    android:topLeftRadius="60dp"
    android:topRightRadius="60dp"/>
</shape>

set half_circle.xml as background of layout

output will be look like :

enter image description here

Community
  • 1
  • 1
Mahendra Gohil
  • 380
  • 1
  • 3
  • 21
2

You can draw the whole view with the help of Canvas in android. And use the Path to define how it will be and Paint object to define its color.