Drawing graphics directly using XML
We can also draw graphics in android using XML .
First i need to create a blank project called "Drawing"
Then make a new file inside the drawable folder called rect.xml.
![]() |
| Creating a new xml file |
I write this codes inside my rect.xml:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="#FFFF0000"
android:endColor="#80FF00FF"
android:angle="45"/>
<padding
android:left="7dp"
android:right="7dp"
android:top="7dp"
android:bottom="7dp"/>
<corners android:radius="10dp"/>
</shape>
![]() |
| Animation.xml |

