I am attempting to use vector drawables in my Android app. From http://developer.android.com/training/material/drawables.html (emphasis mine):
In And
I solve my problem just change size of vector image. From the first it was resource like:
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="24dp"
android:height="24dp"
android:viewportHeight="300"
android:viewportWidth="300">
And I've changed it to 150dp (size of ImageView in layout with this vector resource) like:
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="150dp"
android:height="150dp"
android:viewportHeight="300"
android:viewportWidth="300">
It's working for me.
I try must of these ways but unfortunately, none of them worked.
I try fitXY
in ImageView
, I try using app:srcCompat
but cannot even use it.
but I found a trick way:
set the Drawable to
background
of yourImageView
.
But the point of this way is Views dimensions. if your ImageView
has incorrect dimensions, drawable gets Stretch. you must control it in pre-lollipop versions or Use some Views PercentRelativeLayout
.
Hope it's helpful.