How to create different type shape in android java
Android DevelopmentHello, wonderful friends today in this blog on learning in android XML files creating different types of shape creating. A shape is an XML file that defines a geometric shape, including strokes, colors, and gradients
First Creating .xml file:
- Open android studio
- Go to drawable
- Right-click drawable menu
Follow below image steps:
Now friend starts coding:
- Creating a capsule shape flow below code:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
<corners
android:bottomLeftRadius="30dp"
android:bottomRightRadius="30dp"
android:radius="60dp"
android:topLeftRadius="30dp"
android:topRightRadius="30dp"/>
Corners:
The below image is showing the shape corner radius
Solid:
Solid means shape inner color “#CFCFCF”
Padding:
There is always developer confusion between padding and margin. Both provide extra space/gap inside or outside the container. In simple words, margin means to push outside, whereas padding means to push inside.
Size:
It's very simple shape width - height