How to create a curved bottom border rectangle in android?
how to create android drawable with perfect curved bottom using xml like this:
I tried this xml but the result did not succeed
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#5f9c63"/>
<padding android:left="1dp"
android:top="1dp"
android:right="1dp"
android:bottom="1dp" />
<corners android:bottomRightRadius="100dp"
android:bottomLeftRadius="100dp"
android:topLeftRadius="0dp"
android:topRightRadius="0dp"/>
</shape>
Any idea?
thank
source to share
I think you are looking for something like this: -
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="48dp"
android:height="48dp"
android:viewportHeight="12"
android:viewportWidth="12">
<path
android:fillColor="@android:color/holo_red_light"
android:pathData="M 2,9 C 2,9 4,10 6,10 C 8,10 10,9 10,9 L 10,0 2,0 2,8"
android:strokeWidth="0.1"/>
</vector>
Use the latest vector version of Android, which gives you more drawing possibilities and better results. You can control the drawing pixel by pixel.
Let me add a few options so you can get a clear idea of ββwhat small changes can be made in vector drawings.
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="48dp"
android:height="48dp"
android:viewportHeight="12"
android:viewportWidth="12">
<path
android:fillColor="@android:color/holo_red_light"
android:pathData="M 2,9 C 2,9.5 4,10 6,10 C 8,10 10,9.5 10,9 L 10,0 2,0 2,8"
android:strokeWidth="0.1"/>
</vector>
In this second image, you can see that the curve is more rounded by changing a small value. If you really want to learn about using vector drawings, please refer here , it will give you a great experience with portable vector.
source to share
You can use the oval
form as shown below.
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:bottom="0dp"
android:left="-160dp"
android:right="-160dp"
android:top="-80dp">
<shape android:shape="oval">
<solid android:color="@color/colorPrimary"/>
</shape>
</item>
</layer-list>
You can change left
, right
, top
the value to make the curve more or less.
source to share
Also you can use this method
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:height="300dp"
android:bottom="0dp"
android:left="-60dp"
android:right="-60dp"
android:top="-80dp">
<shape android:shape="oval">
<solid android:color="@color/colorPrimary"/>
</shape>
</item>
</layer-list>
source to share