Vector drawable - correct way to use with the support library

Michael_ShapiroMichael_Shapiro USMember ✭✭✭

Can someone educate me on the proper way of using vector graphics instead of PNGs, please? I've read bunch of articles and searched. Honestly.

The app is compatible with Android 4.4 to the latest. Currently my images are PNG files and stored in Resources/Drawable-mdpi ... /hdpi ... /xhdp ... etc. I reference an image either in the xml layout file android:drawableRight="@drawable/ic_menu_settings_24dp"

or programmatically: widget.SetCompoundDrawablesWithIntrinsicBounds(null, null, Android.Support.V4.Content.ContextCompat.GetDrawable(Context, Resource.Drawable.ic_close_temp_24dp), null);

My goal is to get rid of all these images and density folders and replace it with vector graphics. I am not sure how to ensure that the app is still compatible with Android 4.4 and all the way up? Do I put all the xml files (vectors) in the /drawable folder and delete all the other density specific folders? Do I keep refering to the drawable the same exact way as now - in xml or programmatically?

Will a reference like this Button.SetBackgroundResource(Resource.Drawable.SomeImage) not work becasue it does not use the support library?

I am sorry if this is a trivial question, but I honestly could not find a definitive and up-to-date guide how to do it in Xamarin. Thank yo very much.



  • Tracy320Tracy320 Member ✭✭

    I haven't try this, and the idea is so good, so I will try it myself.
    I will come back if I have the result.

Sign In or Register to comment.