Tint Android vector menu icons through XML -
i've read answers , blog posts explaining vectordrawables in android , how can used instead of png files of different pixel densities.
i've seen there android:tint
xml attribute can used on imagebutton
s , similar view
s, want able apply tint vector icons use menu items, unable use android:tint
on menu items.
one blog post explained tinted drawables can created so:
<?xml version="1.0" encoding="utf-8"?> <bitmap xmlns:android="http://schemas.android.com/apk/res/android" android:src="@drawable/ic_action_something" android:tint="@color/color_action_icons_tint"/>
where xml file above tinted drawable, referenced drawable through src
original vector (black), , tint
colour icon tinted to.
however, above did not work me, giving me following error:
android.content.res.resources$notfoundexception: file res/drawable/ic_chevron_left_white_24dp.xml drawable resource id #0x7f02007e @ android.content.res.resources.loaddrawableforcookie(resources.java:3735) @ android.content.res.resources.loaddrawable(resources.java:3603) @ android.content.res.resources.getdrawable(resources.java:1852) @ android.content.context.getdrawable(context.java:408) @ android.support.v4.content.contextcompatapi21.getdrawable(contextcompatapi21.java:26) @ android.support.v4.content.contextcompat.getdrawable(contextcompat.java:352) @ android.support.v7.widget.appcompatdrawablemanager.getdrawable(appcompatdrawablemanager.java:193) @ android.support.v7.widget.appcompatdrawablemanager.getdrawable(appcompatdrawablemanager.java:181) @ ... caused by: org.xmlpull.v1.xmlpullparserexception: binary xml file line #2: <bitmap> requires valid src attribute @ android.graphics.drawable.bitmapdrawable.updatestatefromtypedarray(bitmapdrawable.java:761) @ android.graphics.drawable.bitmapdrawable.inflate(bitmapdrawable.java:726) @ android.graphics.drawable.drawable.createfromxmlinner(drawable.java:1150) @ android.graphics.drawable.drawable.createfromxml(drawable.java:1063) @ android.content.res.resources.loaddrawableforcookie(resources.java:3719) @ android.content.res.resources.loaddrawable(resources.java:3603) @ android.content.res.resources.getdrawable(resources.java:1852) @ android.content.context.getdrawable(context.java:408) @ android.support.v4.content.contextcompatapi21.getdrawable(contextcompatapi21.java:26) @ android.support.v4.content.contextcompat.getdrawable(contextcompat.java:352) @ android.support.v7.widget.appcompatdrawablemanager.getdrawable(appcompatdrawablemanager.java:193) @ android.support.v7.widget.appcompatdrawablemanager.getdrawable(appcompatdrawablemanager.java:181) @ ...
edit: drawable ic_chevron_left_white_24dp.xml
:
<?xml version="1.0" encoding="utf-8"?> <bitmap xmlns:android="http://schemas.android.com/apk/res/android" android:src="@drawable/ic_chevron_left_black_24dp" android:tint="@color/white"/>
both above file, , referenced 1 exist.
furthermore, above, ide (android studio) displays warning:
rendering problems : requires valid 'src' attribute
this leads me question - how can tint xml vector drawable menu icon?
i aware can create copy of vector , change fillcolor
attribute colour want, apart this, there way non-programmatically?
Comments
Post a Comment