1

Is there method to show xml string into an imageview?

Here is my xml image

<vector xmlns:android="http://schemas.android.com/apk/res/android" xmlns:aapt="http://schemas.android.com/aapt"
    android:viewportWidth="32"
    android:viewportHeight="32"
    android:width="32dp"
    android:height="32dp">
    <group
        android:translateX="2"
        android:translateY="2.005">
        <group
            android:translateX="-0.00000004291534"
            android:translateY="-0.0007002193">
            <group
                android:scaleX="0.8747256"
                android:scaleY="0.8747256">
                <path
                    android:pathData="M31.95 16A15.95 11.95 0 0 1 0.05 16A15.95 11.95 0 0 1 31.95 16Z"
                    android:fillColor="#B3B3B3" />
            </group>
        </group>
        <group
            android:translateY="-0.0007002384">
            <group
                android:scaleX="0.8747256"
                android:scaleY="0.8747256">
                <path
                    android:pathData="M16 4.1C24.77 4.1 31.9 9.44 31.9 16C31.9 22.56 24.77 27.9 16 27.9C7.23 27.9 0.1 22.56 0.1 16C0.1 9.44 7.23 4.1 16 4.1M16 4C7.16 4 0 9.37 0 16C0 22.63 7.16 28 16 28C24.84 28 32 22.63 32 16C32 9.37 24.84 4 16 4L16 4z"
                    android:fillColor="#000000" />
            </group>
        </group>
        <group
            android:translateX="-0.0000004005432"
            android:translateY="-0.0007002193">
            <group
                android:scaleX="0.8747256"
                android:scaleY="0.8747256">
                <path
                    android:pathData="M5.14 27.95C4.54 27.95 4.05 27.46 4.05 26.86L4.05 5.14C4.05 4.54 4.54 4.05 5.14 4.05L26.87 4.05C27.47 4.05 27.96 4.54 27.96 5.14L27.96 26.87C27.96 27.47 27.47 27.96 26.87 27.96L5.14 27.96z"
                    android:fillColor="#E6E6E6" />
            </group>
        </group>
        <group
            android:translateX="-0.0000004768372"
            android:translateY="-0.0007002384">
            <group
                android:scaleX="0.8747256"
                android:scaleY="0.8747256">
                <path
                    android:pathData="M26.86 4.1C27.43 4.1 27.9 4.56 27.9 5.14L27.9 26.87C27.9 27.44 27.44 27.91 26.86 27.91L5.14 27.91C4.57 27.91 4.1 27.45 4.1 26.87L4.1 5.14C4.1 4.57 4.56 4.1 5.14 4.1L26.86 4.1M26.86 4L5.14 4C4.51 4 4 4.51 4 5.14L4 26.87C4 27.49 4.51 28 5.14 28L26.87 28C27.5 28 28.01 27.49 28.01 26.86L28.01 5.14C28 4.51 27.49 4 26.86 4L26.86 4z"
                    android:fillColor="#000000" />
            </group>
        </group>
    </group>
</vector>

I have search but I didn't found if there is any method I can convert this xml string image to imageview. Image are loaded each time from server as string. And I want to show them into an imageview

Lino
  • 5,084
  • 3
  • 21
  • 39
dbsoft
  • 31
  • 5
  • This is a vector image, usually resulted from a SVG. You should place this code into drawable folder (you should create a new file manually since you already have it as code) and load it in your ImageView as `imageview.setImageResource(R.drawable.xyz);` where `xyz` is your name for new created file. – Cătălin Florescu Feb 11 '23 at 16:57
  • you can start from this https://stackoverflow.com/a/49920860/2442831 – Lino Feb 11 '23 at 17:03

0 Answers0