Cannot load vector Drawable in bitmap in XML
Asked Answered
I

0

6

This is my first code that loads a Vector-Drawable in layer-list. it works fine.Later I had to change color of my vector drawable. I find that I should add bitmap to use tint attribute. This is my first code and vector drawable show fine in layer-list.

<item>
    <shape
        android:padding="1dp"
        android:shape="oval">
        <corners
            android:bottomLeftRadius="5dp"
            android:bottomRightRadius="5dp"
            android:topLeftRadius="5dp"
            android:topRightRadius="5dp"/>
        <solid android:color="@color/accent"/>
    </shape>
</item>
<item android:drawable="@drawable/ic_check_black_24px"/> // this is vector drawable

so I changed my code to this. I can not load vector-Drawable in bitmap in XML.

<item>
    <shape
        android:padding="1dp"
        android:shape="oval">
        <corners
            android:bottomLeftRadius="5dp"
            android:bottomRightRadius="5dp"
            android:topLeftRadius="5dp"
            android:topRightRadius="5dp"/>
        <solid android:color="@color/accent"/>
    </shape>
</item>
<item>
    <bitmap
        android:src="@drawable/ic_check_black_24px"
        android:tint="@color/white"/>
</item>

problem is here. I cannot load vector-drawable in bitmap,it causes to crash my app.

Inclinable answered 25/12, 2016 at 10:36 Comment(8)
Possible duplicate of How to get a Bitmap from VectorDrawablePatronage
I think we are not same cause I'm doing in XMLInclinable
are you using android.support.graphics.drawable.VectorDrawableCompat?Poltroonery
@Poltroonery in where?Inclinable
what "in where"? are you using support vector drawable?Poltroonery
@Poltroonery after 23.4.0 there is no need to put vectorDrawables.useSupportLibrary=true in gradle. I use vectors without this annotationInclinable
i did not ask about vectorDrawables.useSupportLibrary, i asked if you are using vector drawables from support library (VectorDrawableCompat)Poltroonery
@Poltroonery as you see in my code, No. how I can use it?Inclinable

© 2022 - 2024 — McMap. All rights reserved.