【问题标题】:how to add border(stroke) line in heart shape drawable xml如何在心形可绘制 xml 中添加边框(描边)线
【发布时间】:2019-01-22 09:52:54
【问题描述】:
  • 如下所示,我绘制了类似心形的可绘制 xml
  • 但我想添加边框线,如(笔画)
  • 我遇到了一些困难如何添加该行

    <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"/>
    

【问题讨论】:

  • 添加android:strokeColorandroid:strokeWidth
  • 您可以使用android:strokeWidthandroid:strokeColor 并删除fillColor。所有属性都应该在路径标签内
  • pathdata 只不过是我给出的形状.....

标签: android xml android-vectordrawable android-shape


【解决方案1】:

试试这个

<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>

输出

【讨论】:

    【解决方案2】:

    您可以像在可绘制 xml 中一样在路径中添加 stroke 属性。请参见下面的示例。

    <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"/>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-12-18
      • 2014-10-07
      • 1970-01-01
      • 1970-01-01
      • 2022-12-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多