Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

Load Svg from String #65

Open
selmantsn opened this issue Jun 9, 2020 · 2 comments
Open

Load Svg from String #65

selmantsn opened this issue Jun 9, 2020 · 2 comments

Comments

@selmantsn
Copy link

selmantsn commented Jun 9, 2020

Ex:

<svg width="285" height="350" viewBox="0 0 285 350" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M0.725098 20.775C0.725098 9.78453 9.63483 0.875 20.6251 0.875H194.75L284.3 90.425V329.225C284.3 340.215 275.39 349.125 264.4 349.125H20.6251C9.63483 349.125 0.725098 340.215 0.725098 329.225V20.775Z" fill="url(#paint0_linear)"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M194.75 0.875V70.525C194.75 81.5153 203.66 90.425 214.65 90.425H284.3L194.75 0.875Z" fill="url(#paint1_linear)"/>
<defs>
<linearGradient id="paint0_linear" x1="0.725098" y1="0.875" x2="0.725098" y2="349.125" gradientUnits="userSpaceOnUse">
<stop offset="1" stop-color="#FFCA8A"/>
</linearGradient>
</defs>
</svg>

I have a kind of SVG content string. Is there any way to load from string to RichPathView?

@tarek360
Copy link
Owner

@selmantsn

No, RichPath doesn't read SVG, you need to convert your SVG to the VectorDrawable format!
Then, you need to save your VectorDrawable in the resources!

It's easy to convert your example to VectorDrawable format, here it is 👇

<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
  android:width="285dp"
  android:height="350dp"
  android:viewportWidth="285"
  android:viewportHeight="350">

  <path
    android:fillColor="#FFFFCA8A"
    android:pathData="M0.725098 20.775C0.725098 9.78453 9.63483 0.875 20.6251 0.875H194.75L284.3 90.425V329.225C284.3 340.215 275.39 349.125 264.4 349.125H20.6251C9.63483 349.125 0.725098 340.215 0.725098 329.225V20.775Z" />
  
  <path
    android:fillColor="#FFAE4E"
    android:pathData="M194.75 0.875V70.525C194.75 81.5153 203.66 90.425 214.65 90.425H284.3L194.75 0.875Z" />

</vector>

You may already know that, so if your case is different, please explain more and we may find a good idea for your case!

@selmantsn
Copy link
Author

@tarek360 This SVG content I mentioned comes from my api service as a string. So I have to convert this somehow from string. And also every "evenodd" path has a id. I should give click event in this path. If user click these paths, it will do something with id.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants