I am using the following code to get rounded corners as well as a colored outline:
<?xml version="1.0" encoding="UTF-8"?>
<gradient android:startColor="@color/white" android:endColor="@color/white" /> <corners android:bottomRightRadius="2dp" android:bottomLeftRadius="2dp" android:topLeftRadius="2dp" android:topRightRadius="2dp"/> <stroke android:width="5dip" android:color="@color/black" />
The image displays what I'm getting right now. Due to the stroke
, the rounded corners only lie on the outer edge of the layout and the inner edge of the black outline makes a rectangle with sharp edges. How can I convert the sharp edges to rounded corners?
In the upper left corner, select “Draw Filled Shape“. Draw the rounded rectangle over the area you would like to keep for your rounded corners image. Use the Magic Wand to select the area of the rounded rectangle. Select “Edit” > “Invert Selection“.
The border-radius property defines the radius of the element's corners. Tip: This property allows you to add rounded corners to elements! This property can have from one to four values.
Use the <shape>
tag to create a drawable in XML with rounded corners. (You can do other stuff with the shape tag like define a color gradient as well).
Following code may help you:
<?xml version="1.0" encoding="UTF-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <solid android:color="#ffffffff"/> <stroke android:width="3dp" android:color="#ff000000" /> <padding android:left="1dp" android:top="1dp" android:right="1dp" android:bottom="1dp" /> <corners android:bottomRightRadius="7dp" android:bottomLeftRadius="7dp" android:topLeftRadius="7dp" android:topRightRadius="7dp"/> </shape>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With