0
  • As below I draw drawable xml like heart shape
  • But I want to add border line like (stroke)
  • I am facing some difficulty how can I add that line

    <path
        android:fillColor="#a39f9f"
        android:pathData="M12,21.35l-1.45,-1.32C5.4,15.36 2,12.28 2,8.5 2,5.42 4.42,3 7.5,3c1.74,0 3.41,0.81 4.5,2.09C13.09,3.81 14.76,3 16.5,3 19.58,3 22,5.42 22,8.5c0,3.78 -3.4,6.86 -8.55,11.54L12,21.35z"/>
    

Vivek Mishra
  • 5,669
  • 9
  • 46
  • 84
PRP
  • 101
  • 9
  • 2
    add `android:strokeColor` and `android:strokeWidth` – pskink Jan 22 '19 at 09:56
  • you can use `android:strokeWidth` and `android:strokeColor` and remove fillColor. All attributes should be inside path tag – Rahul Jan 22 '19 at 09:56
  • pathdata is nothing but shape i am giving .......... – PRP Jan 22 '19 at 09:57
  • Possible duplicate of [how to create android:pathData?](https://stackoverflow.com/questions/36677768/how-to-create-androidpathdata) – MadLeo Jan 22 '19 at 09:59

2 Answers2

5

Try this

<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:fillColor="#a39f9f"
        android:strokeColor="#ff0"
        android:strokeWidth="2"
        android:pathData="M12,21.35l-1.45,-1.32C5.4,15.36 2,12.28 2,8.5 2,5.42 4.42,3 7.5,3c1.74,0 3.41,0.81 4.5,2.09C13.09,3.81 14.76,3 16.5,3 19.58,3 22,5.42 22,8.5c0,3.78 -3.4,6.86 -8.55,11.54L12,21.35z"/>

</vector>

OUTPUT

enter image description here

AskNilesh
  • 67,701
  • 16
  • 123
  • 163
1

You can add the stroke attribute in your path just as you do in the drawable xmls. See the below example.

<path android:fillColor="#417505" android:fillType="evenOdd"
    android:pathData="M11,0L11,0A11,11 0,0 1,22 11L22,11A11,11 0,0 1,11 22L11,22A11,11 0,0 1,0 11L0,11A11,11 0,0 1,11 0z"
    android:strokeColor="#000" android:strokeWidth="2"/>
Vivek Mishra
  • 5,669
  • 9
  • 46
  • 84