android-vectordrawable

Android how to resize (scale) an xml vector icon programmatically

折月煮酒 提交于 2019-12-21 04:26:29
问题 This is driving me crazy. I would like to be able to resize an xml vector drawable icon programmatically in order to use it in an ImageView. This is what I've done so far which is not working Drawable drawable = ResourcesCompat.getDrawable(getResources(),R.drawable.ic_marker,null); drawable.setBounds(0,0,512,512); imageVenue.setImageDrawable(drawable); The vector icon ic_marker is not resized. It just keeps the hardcoded width and height values every time. Any ideas? 回答1: You can change the

Android Nougat cannot show certain vector files (Resources$NotFoundException)

橙三吉。 提交于 2019-12-20 23:25:17
问题 I have been working on an app that contains a number of vector graphics. Recently I started testing it on Nougat and found it crashing immediately. The logcat shows a Resources$NotFoundException while loading a vector which is reminiscent of all the AppCompat errors in earlier versions of Android with vector graphics. However, it runs fine on KitKat, Lollipop, and Marshmallow. It is only on Nougat that I am getting this error. I have narrowed it down to a certain number of vector files that

Youtube Play/pause Animated Vector Drawable on android

旧街凉风 提交于 2019-12-20 15:09:08
问题 I'm trying to do an animation like youtube Play/Pause with svgs paths and animated vector. Strings.xml <resources> <string name="app_name">AnimatedSvgTest</string> <string name="svg_triangle"> M0,0 L0,24 12,12 0,0 </string> <string name="svg_pause"> M0,0 L0,24 M12,0 L12,24 </string> </resources> anim/path_morph.xml : <set xmlns:android="http://schemas.android.com/apk/res/android"> <objectAnimator android:duration="4000" android:propertyName="pathData" android:valueFrom="@string/svg_triangle"

What is the impact of viewportwidth/height on Android drawables

流过昼夜 提交于 2019-12-20 08:32:52
问题 I have an vector drawable I imported from an SVG asset. Sometimes, I have to adjust the size. Usually I update width and height. What I can't work out is how viewportwidth and height also impact the svg. It seems changing these dimensions can push the svg out of view within the visible area. What do these units of measurement represent ? What is it's relationship with width and height respectively ? The documentation from Google is, (as usual), woefully inadequate. Could someone please

How to center vector drawable in layer-list without scaling

半世苍凉 提交于 2019-12-20 08:09:59
问题 I am attempting to use a VectorDrawable in a LayerList without scaling the vector. For example: <layer-list> <item android:drawable="@color/grid_item_activated"/> <item android:gravity="center" android:drawable="@drawable/ic_check_white_48dp"/> </layer-list> The drawable ic_check_white_48dp id defined as: <vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="48dp" android:height="48dp" android:viewportWidth="24.0" android:viewportHeight="24.0"> <path android

How to create vector drawables for android?

那年仲夏 提交于 2019-12-20 07:58:18
问题 I am new to VectorDrawables . I can see that the default vector drawables provided with android studio like ic_menu_gallery , ic_menu_camera , etc. are working great. So I tried to create my own vector drawables by converting my png images to svg first and using the path and fill values to make vector drawables i.e replaced the android:pathData for d and android:fillColor for fill tag in svg files. It somehow gave vector drawables but distorted or currputed looking. If I am not taking the

Convert Android vector drawable to launcher icon PNG

我只是一个虾纸丫 提交于 2019-12-20 07:14:27
问题 I've made Android launcher icon as vector but I found out that I should use PNGs instead of vector(XML). How can I convert my vector image to PNGs for launcher icon. This is vector if it's of any help: <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android" android:width="100dp" android:height="100dp"> <item> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval"> <solid android:color="#5FB0C9"/> <size

SVG/VectorDrawable issue in android

a 夏天 提交于 2019-12-20 05:41:14
问题 I have used svg files in my Android project. There are issues in Android 4.4 or lower versions. I have tried these solutions app:srcCompat , vectorDrawables.useSupportLibrary = true in gradle file and AppCompatDelegate.setCompatVectorFromResourcesEnabled(true); in static block of BaseActivity . Other than gridview, images are not shown in app . 回答1: Instead of using above 3 solutions, just replace your ImageView with android.support.v7.widget.AppCompatImageView . No need to do any extra

Programmatically tint a Support Vector

陌路散爱 提交于 2019-12-18 12:53:04
问题 Android Studio version 2.1, gradle version 2.1.0, please correct me if you spot any misinterpretations :) I am confused about support vectors in the support library 23.3.0. Specifically what I would like to do is tint an image button programmatically, whose src is defined is a vector drawable. From what I can tell this is not possible on pre-lollipop now. I have read several related posts about the changes: 23.2.0 announcement and changes: As of Android Support Library 23.3.0, support vector

Change fillColor of a vector in android programmatically

若如初见. 提交于 2019-12-18 12:45:55
问题 I want to edit the fill Color of a vector-file in Android programmatically. In the xml-file I can set my color with the attribute android:fillColor but I want to change the color in runtime. Any examples for that? Thanks. 回答1: This is exactly what you need. Credits to @emmaguy, the author of the post. I just added the full support of Support Library 23.4+, which enables you to stop generating pngs at runtime: // Gradle Plugin 2.0+ android { defaultConfig { vectorDrawables.useSupportLibrary =