https://kotlinlang.org logo
#android
Title
# android
n

Nikola Milovic

12/11/2019, 6:17 PM
Hey guys, problem with vector drawables and styles. So I have two options, etiher use android:src or android:background to set the vector image. The src allows me to change the tint of the drawable but not the size, while background lets me set the size but not the tint. Any way to change both color and size in xml style?
Copy code
<style name="ImageButtonStyle" parent="Widget.AppCompat.ImageButton">
        <item name="android:color">@color/secondaryColor</item>
        <item name="android:tint">@color/secondaryColor</item> // works as its src now
        <item name="android:layout_width">80dp</item> //doesnt work
        <item name="android:layout_height">80dp</item> // doesnt work
        <item name="android:background">@android:color/transparent</item>
    </style>
Copy code
android:src="@drawable/ic_favorite"
t

tseisel

12/11/2019, 7:05 PM
This is a Kotlin Slack, this is for Android questions that are specific to Kotlin (some examples are Dagger + Kotlin, app architecture with coroutines, patterns provided by the language for Android development, etc.).
You may find an answer on StackOverflow. if you don't, try the following : 1. Change the
width
and
height
of your
<vector>
to fit your needs 2. Set the drawable as the background, and specify
android:backgroundTint
3. Set as
src
and tweak the
scaleType