Android studio import svg pictures: Gradient has no stop info

Please indicate the source!

I recently tried to draw icons with vector, but the pure code is too troublesome and I don’t want to learn. .
So use Inkscape to draw the svg icon and import the vector asset in android studio.
An error occurred: line XX: Gradient has no stop info .
I found a related answer: Gradient has no stop info error while importing SVG file in Android Studio. It is
believed that Android Studio cannot resolve xlink:href="#linearGradient6105"the stop information (gradient information) in the quote ; so the quoted value is written directly to the quote to solve it.

  1. Right-click the svg file to open it in text form, and find the context of the number of error lines:
  <defs
     id="defs3721">
    <linearGradient
       id="linearGradient6105">
      <stop
         id="stop6101"
         offset="0"
         style="stop-color:#7dc0f3;stop-opacity:1;" />
      <stop
         id="stop6103"
         offset="1"
         style="stop-color:#7dc0f3;stop-opacity:0;" />
    </linearGradient>
    <linearGradient
       osb:paint="solid"
       id="linearGradient6020">
      <stop
         id="stop6018"
         offset="0"
         style="stop-color:#ffc2ea;stop-opacity:1;" />
    </linearGradient>
    <linearGradient
       osb:paint="solid"
       id="linearGradient6012">
      <stop
         id="stop6010"
         offset="0"
         style="stop-color:#ffc2ea;stop-opacity:1;" />
    </linearGradient>
    <linearGradient
       gradientUnits="userSpaceOnUse"
       y2="19.608416"
       x2="91.915047"
       y1="41.236385"
       x1="64"
       id="linearGradient6107"
       xlink:href="#linearGradient6105" /> <!-- 报错行数 -->
  </defs>
  1. The quoted is defined as "#linearGradient6105":
<linearGradient
       id="linearGradient6105">
      <stop
         id="stop6101"
         offset="0"
         style="stop-color:#7dc0f3;stop-opacity:1;" />
      <stop
         id="stop6103"
         offset="1"
         style="stop-color:#7dc0f3;stop-opacity:0;" />
    </linearGradient>

Rewrite and save to the reference:

    <defs
     id="defs3721">
    <linearGradient
       osb:paint="solid"
       id="linearGradient6020">
      <stop
         id="stop6018"
         offset="0"
         style="stop-color:#ffc2ea;stop-opacity:1;" />
    </linearGradient>
    <linearGradient
       osb:paint="solid"
       id="linearGradient6012">
      <stop
         id="stop6010"
         offset="0"
         style="stop-color:#ffc2ea;stop-opacity:1;" />
    </linearGradient>
    <linearGradient
       gradientUnits="userSpaceOnUse"
       y2="19.608416"
       x2="91.915047"
       y1="41.236385"
       x1="64"
       id="linearGradient6107" >
      <stop
         id="stop6101"
         offset="0"
         style="stop-color:#7dc0f3;stop-opacity:1;" />
      <stop
         id="stop6103"
         offset="1"
         style="stop-color:#7dc0f3;stop-opacity:0;" />
       </linearGradient>
  </defs>
  1. That's it! Re-import into Android Studio, no more errors.

Guess you like

Origin blog.csdn.net/zsq8187/article/details/103904049