在 HTML 中,<polyline>
可用于生成类似于折线图的点。
<!-- html -->
<svg viewBox="0 0 700 200" class="chart">
<polyline
fill="none"
stroke="#bd4c4a"
stroke-width="3"
points="
0,120
20,60
40,80
60,20
80,30
100,10
120,70"/>
</svg>
生成这样的图形:
但是在 xml 中似乎只有 <path>
被识别,除了使用 path 元素而不像这样编写之外,是否有一种方法可以模仿 XML 中 <polyline>
的功能:
<!-- XML -->
<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="#FF000000"
android:strokeColor="@color/black"
android:pathData="M 5 9 l 2 -6 M 9 6 L 7 3 M 11 1 L 9 6 M 13 7 L 11 1 M 15 4 L 13 7" />
</vector>