Search code examples
javaandroidandroid-vectordrawable

How to manually write vector drawable pathData in android xml


I need help in finding good tutorials on how to manually code a vector drawable like the one below. I have tried surfing the net but I haven't found any good information.

<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="24dp"
    android:height="24dp"
    android:viewportWidth="24.0"
    android:viewportHeight="24.0">
<path
    android:pathData="M12,14c1.66,0 2.99,-1.34 2.99,-3L15,5c0,-1.66 -1.34,-3 -3,-3S9,3.34 9,5v6c0,1.66 1.34,3 3,3zM17.3,11c0,3 -2.54,5.1 -5.3,5.1S6.7,14 6.7,11L5,11c0,3.41 2.72,6.23 6,6.72L11,21h2v-3.28c3.28,-0.48 6,-3.3 6,-6.72h-1.7z"
    android:fillColor="#000000"/>

Solution

  • There are five line commands for nodes. The first command is the "Move To" or M, which was described above. It takes two parameters, a coordinate (x) and coordinate (y) to move to. If the cursor was already somewhere on the page, no line is drawn to connect the two positions. The "Move To" command appears at the beginning of paths to specify where the drawing should start. For example:

    M x y (or) m dx dy

    <svg width="200" height="200" xmlns="http://www.w3.org/2000/svg">
    
    <path d="M10 10"/>
    
    <!-- Points -->
    <circle cx="10" cy="10" r="2" fill="red"/>
    
    </svg>
    

    There are three commands that draw lines. The most generic is the "Line To" command, called with L. L takes two parameters—x and y coordinates—and draws a line from the current position to a new position.

    L x y (or) l dx dy

    link