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 | 
this is done by changing  the background of button :
android:background="@drawable/rec"
![]()  | 
| Adding drawing animation in button | 
And the button looks like this:




No comments:
Post a Comment
Did this post help you? Do you have any questions? Drop your thoughts here...