2

I want custom shape border like the one shown below:

enter image description here

This is what i have tried so far:

<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="#00000000"/>
    <stroke android:width="0.1dp" android:color="#FFFFFF" />
    <corners android:radius="5dp"/>
    <!--<padding android:left="5dp" android:top="5dp" android:right="5dp" android:bottom="5dp" />-->
</shape>

But this does not give me curvy sides,only curvy corners.

I need curvy sides

user6265154
  • 353
  • 1
  • 6
  • 19

2 Answers2

6

Look at this when change the drawable to this you will get the following output.

 <ImageView
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:layout_marginLeft="100dp"
            android:layout_marginTop="25dp"
            android:src="@drawable/rectangle" />

rectangle.xml file is

<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="#000000" />
    <stroke
        android:width="1dp"
        android:color="#FFFFFF" />
    <corners android:radius="20dp" />
    <padding
        android:bottom="5dp"
        android:left="5dp"
        android:right="5dp"
        android:top="5dp" />
</shape>

ScreenShot :

enter image description here

Harshad Pansuriya
  • 20,189
  • 8
  • 67
  • 95
  • can you please help me out on this [http://stackoverflow.com/questions/43412704/how-to-draw-a-dot-circle-inside-a-square-drawable-in-android](http://stackoverflow.com/questions/43412704/how-to-draw-a-dot-circle-inside-a-square-drawable-in-android) – Siddarth G Apr 18 '17 at 07:44
1

enter image description here

Try like this. Create a drawable

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <solid android:color="@android:color/transparent" />
    <stroke
        android:width="3dp"
        android:color="@android:color/white" />
    <corners android:radius="17dp" />

</shape>

And then use it with any view.

<TextView
   android:layout_width="50dp"
   android:textColor="@android:color/white"
   android:background="@drawable/rounded_corner"
   android:layout_height="50dp"
   android:gravity="center"
   android:text="T" />

Change the radious and the height and width according to your need. Please make sure the height and width of the view must be same if you want this type of effect.

Gopal Singh Sirvi
  • 4,539
  • 5
  • 33
  • 55