These are the basic commands for drawing drawable in Android :
- M = moveto
- L = lineto
- H = horizontal lineto
- V = vertical lineto
- C = curveto
- S = smooth curveto
- Q = quadratic Bézier curve
- T = smooth quadratic Bézier curveto
- A = elliptical Arc
- Z = closepath
So let's create a new drawable vector on androd. Right click on drawable folder, choose "new" then "drawable resource file" :
We're going to have a new file like this :aaand... let's try to make a triangle first... :D :D :D
1 2 3 4 5 6 7 8 9 10 11 12 13 | <?xml version="1.0" encoding="utf-8"?> <vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="34dp" android:width="34dp" android:viewportHeight="340" android:viewportWidth="340" > <path android:fillColor="#FF0000" android:pathData="M150,0 L75,200 L225,200 Z" /> </vector> |
So...If we want to draw a start using just L command, the code should be looking like this :
1 2 3 4 5 6 7 8 9 10 11 12 13 | <?xml version="1.0" encoding="utf-8"?> <vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="34dp" android:width="34dp" android:viewportHeight="340" android:viewportWidth="340" > <path android:fillColor="#90FF0F" android:pathData="M150,0 L75,200 L245,75 L55,75 L225,200 Z" /> </vector> |
Continue to Part II...
No comments:
Post a Comment