Read More

Creating TextViews with Drawable and supporting vector images in it

As we know this is the age of vector for android. But there is some constraints even in the latest support libraries. One such is setting vector image for the drawable associated with the text view.

screenshot_1

In order to add vector drawable images/icons in the drawable of a text view. We can use the following workaround. Until Android guys don’t come up with the updated libraries.

The idea is of adding vector image inside a layer-list or selector drawable and then setting it directly.

 

Here is the example:

/* ic_wishlist_wrapper.xml */

/* ic_wishlist.xml */

and now setting ic_wishlist_wrapper instead of ic_wishlist will do the trick.

 

Hope this trick works for you and you continue to support more and more VectorDrawables.

 

UI
. . .

Comment (1)

Add Your Comment

  • Bukenya Charles Lusansa
    Didn’t work for me
  • css.php
    Hire Us!
    Brief us about your requirements and we'll get back to you.
    Woo! Hooy!
    We have just recieved your project brief and our expert will contact you shortly.
    Send Again
    Close