android-vectordrawable

AppCompat 23.2 use VectorDrawableCompat with RemoteViews (AppWidget) on API<21

左心房为你撑大大i 提交于 2019-11-27 20:27:01
I have an AppWidget and I'd like to use VectorDrawables in it also on pre-Lollipop devices. VectorDrawableCompat won't work with the RemoteViews I create. To keep my app APK size down, I don't want to add alternative PNG versions of my drawables for older API platforms. How can I do that? UPDATE 22/10/2017 As noted by @user924 now AppCompatDrawableManager access is restricted to its own library. ContextCompat.getDrawable(...) should do the trick. UPDATE 05/09/2016 As noted by @kirill-kulakov in its answer, the latest updates of the Support Library restricted the TintContextWrapper visibility

Support library VectorDrawable Resources$NotFoundException

放肆的年华 提交于 2019-11-27 17:16:51
I am using Design Support Library version 23.4.0 . I have enabled the gradle flag: defaultConfig { vectorDrawables.useSupportLibrary = true } I am using build tools version 23.0.2 , but still, I am getting Resources$NotFoundException on KitKat or lower. It is occurring when I use android:drawableLeft or imageView.setImageResource(R.drawable.drawable_image) . And yes, I am putting this on every activity where I am using drawables static { AppCompatDelegate.setCompatVectorFromResourcesEnabled(true); } Is this a bug of the support library? It took 3 separate things for me to get this to work

Can GradientColor be used to define a gradient for a fill or stroke entirely in XML?

最后都变了- 提交于 2019-11-27 13:12:11
I was looking at the documentation for GradientColor https://developer.android.com/reference/android/R.styleable.html#GradientColor . How can I define a gradient color in XML and apply it to an XML vector drawable? I have tried in color.xml, styles.xml and within an XML vector drawable. I get the error " Failed to convert @id/gradclor into a ColorStateList" with: <?xml version="1.0" encoding="utf-8"?> <vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="120dp" android:height="120dp" android:viewportWidth="120.0" android:viewportHeight="120.0"> <path android:name=

Android vectorDrawables.useSupportLibrary = true is stopping app

早过忘川 提交于 2019-11-27 12:11:34
问题 If I use vectorDrawables.useSupportLibrary = true in gradle then run the app it stopped unfortunately. If I remove vectorDrawables.useSupportLibrary = true the app works. My gradle: apply plugin: 'com.android.application' android { compileSdkVersion 25 buildToolsVersion "25.0.2" defaultConfig { vectorDrawables.useSupportLibrary = true applicationId "com.helikanon.firstapp" minSdkVersion 15 targetSdkVersion 25 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test

How to change color of vector drawable path on button click

百般思念 提交于 2019-11-27 12:03:19
With the new android support update, vector drawables get backward compatibility. I have a vector image with various paths. I want the color of the paths to change on click of a button or programmatically based on an input value. Is it possible to access the name parameter of the vector path? And then change the color. Use this to change a path color in your vector drawable VectorChildFinder vector = new VectorChildFinder(this, R.drawable.my_vector, imageView); VectorDrawableCompat.VFullPath path1 = vector.findPathByName("path1"); path1.setFillColor(Color.RED); Library is here: https://github

AppCompat 23.3 Support Vectors no longer work?

谁说我不能喝 提交于 2019-11-27 10:57:18
I was using the support vector drawables added in Support Library 23.2 along with AppCompat. I was using vector drawables both with app:srcCompat and inside a StateListDrawable so I could use them with android:drawableLeft for my TextView. Since upgrading to the 23.3.0 version of AppCompat, only the vectors in app:srcCompat are working. Whenever I reference it the other way I get FATAL EXCEPTION: main java.lang.RuntimeException: Unable to start activity ComponentInfo{com.my.package.name/.MainActivity}: android.view.InflateException: Binary XML file line #8: Error inflating class Button ...

Precise control over Androids VectorDrawable animations

青春壹個敷衍的年華 提交于 2019-11-27 10:49:18
问题 UPDATE: Solution found! Scroll down for my accepted answer! I want to animate multiple elements of one image and link the animation to ViewPagers position (so multiple elements are morphing or flying in/out depending on the current page being dragged). So, is there a way to precisely control the current frame of the animation? For example let's assume i have this set: <?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android"> <objectAnimator

How to use vector drawables with View besides ImageView with srcCompat?

半世苍凉 提交于 2019-11-27 10:16:12
问题 app:srcCompat with ImageView allows for backward compatible use of vector drawables. But how can you use them with other View s besides ImageView ? For example, the TextView attributes like android:drawableLeft . Also using the vector drawable as an android:icon with MenuItem caused a crash with the following exception: Fatal Exception: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown> at android.view.LayoutInflater.createView(LayoutInflater.java:626) at

Change fill color on vector asset in Android Studio

徘徊边缘 提交于 2019-11-27 10:08:15
Android Studio now supports vector assets on 21+ and will generate pngs for lower versions at compile time. I have a vector asset (from the Material Icons) that I want to change the fill color. This works on 21+, but the generated pngs do not change color. Is there a way to do this? <vector android:height="48dp" android:viewportHeight="24.0" android:viewportWidth="24.0" android:width="48dp" xmlns:android="http://schemas.android.com/apk/res/android"> <path android:fillColor="@color/primary" android:pathData="M9,16.17L4.83,12l-1.42,1.41L9,19 21,7l-1.41,-1.41z"/> YYYY-MM-DD Don't edit the vector

VectorDrawableCompat Resources$NotFoundException on KitKat and below

早过忘川 提交于 2019-11-27 09:13:45
When I enable vectorDrawables.useSupportLibrary = true I get a lot of resourceNotFoundExceptions on KitKat and below devices. I get this for NavigationView for Menus and also for ImageViews with app:srcCompat android.content.res.Resources$NotFoundException: Resource ID #0x7f02006b at android.content.res.Resources.getValue(Resources.java:2305) at android.support.v7.widget.AppCompatDrawableManager.loadDrawableFromDelegates(AppCompatDrawableManager.java:268) at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:178) at android.support.v7.widget