I have a problem with rendering vector drawable on Motorola pre-lollipop phones. I tested it on Moto G and other with KitKat. Every time I start application some icons look corrupted and some are missing at all. And after each launch they are corrupted in a different way. On Lenovo, Samsung, AOSP Emulator and others with JB+ till Nougat everything is ok. Only Motorola phones can not render vector drawables with support library well. Does anybody have the same issue?
-
2Please post your code how you are add vector – Lokesh Aug 23 '17 at 08:51
-
already have answer for this question https://stackoverflow.com/questions/34417843/how-to-use-vector-drawables-in-android-api-lower-21 – Lokesh Aug 23 '17 at 08:52
-
I am using it as documentation said. Only motorolla have such issue. Other pre-lollipop devices are ok – Mykhailo Yuzheka Aug 24 '17 at 10:18
-
There are a lot of think related to support vector drawable that is not mentioned in the documentation.Even I have faced a lot of issue with it.Only if you post the code, we will be able to help you as asked by @Lokesh – Farmaan Elahi Aug 24 '17 at 17:29
-
Do you have a small example vector drawable that exhibits these problems? There are a variety of device-specific problems with vector drawables including scientific notation and not having a leading zero for decimal values. The linter in the latest Android Studio 3.0 Preview should point out some of these for you. – kabuko Aug 24 '17 at 22:56
-
are you importing vector drawables from svg's? – VK.N Aug 27 '17 at 18:55
-
yes, I am importing it fom svg and have no warnings there – Mykhailo Yuzheka Aug 28 '17 at 07:07
5 Answers
Vector Drawables are also supported in cases like TextView's drawableLeft property. go this link Android Studio 1.4
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@drawable/icon"

- 321
- 2
- 17
-
https://medium.com/@ferrand.d/can-you-and-should-you-use-vector-drawables-a-cheatsheet-32a2e1cc2ecf – AmmAr Yasser Aug 24 '17 at 22:01
Try adding the following to onCreate() method of your Application class:
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
From official docs:
When enabled, AppCompat can intercept some drawable inflation from the framework, which enables implicit inflation of vector drawables within DrawableContainer resources.
You can then use those drawables in places such as android:src on ImageView, or android:drawableLeft on TextView.
This feature defaults to disabled, since enabling it can cause issues with memory usage, and problems updating Configuration instances.
If you update the configuration manually, then you probably do not want to enable this. You have been warned.

- 569
- 1
- 4
- 13
In my Research I found two ways to support vector drawable on pre lollipop devices. You can try this.
You can support all devices with vector drawable with AppCompatImageView
<android.support.v7.widget.AppCompatImageView
app:srcCompat="" // your drawable declaration
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
android.support.v7.appcompat:srcCompat
Sets a drawable as the content of this ImageView. Allows the use of vector drawable when running on older versions of the platform.
Requires Support Library 23.4.0 or latest
Another way is to configure vector drawable setting in Gradle. Include the below code in your Gradle.
android {
defaultConfig {
vectorDrawables.useSupportLibrary = true
}
}
The use srcCompat
in your ImageView
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@drawable/ic_add" />
Source: https://android-developers.googleblog.com/2016/02/android-support-library-232.html
Hope it helps you :)

- 13,474
- 12
- 40
- 66
If you want to use vector with ImageView, you should use srcCompat-AppCompatImageView. However, if you want to use vector with drawableLeft.. use this library https://github.com/bsobe/vectorview

- 470
- 4
- 7
Try this:::-
Drawable date = AppCompatResources.getDrawable(itemView.getContext(), R.drawable.ic_date_range_black_24dp);
etDeliveryDate.setCompoundDrawablesWithIntrinsicBounds(date, null, null, null);

- 1,409
- 1
- 15
- 38
-
@user3280437 have you removed src or srcCompat drawable path from xml? – Lalit Jadav Aug 28 '17 at 09:06
-
-