U
U
Username2016-05-07 22:05:29
Android
Username, 2016-05-07 22:05:29

How to specify svg color on old android?

Good afternoon, when adding an icon in svg format, you can specify the color:

<vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:width="24dp"
        android:height="24dp"
        android:viewportWidth="24.0"
        android:viewportHeight="24.0">
    <path
        android:fillColor="@color/colorIcon"
        android:pathData="M19,3h-4.18C14.4,1.84 13.3,1 12,1c-1.3,0 -2.4,0.84 -2.82,2H5c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2V5c0,-1.1 -0.9,-2 -2,-2zm-7,0c0.55,0 1,0.45 1,1s-0.45,1 -1,1 -1,-0.45 -1,-1 0.45,-1 1,-1zm2,14H7v-2h7v2zm3,-4H7v-2h10v2zm0,-4H7V7h10v2z"/>
</vector>

But this color is only applied for android above 5 (API 21). Everything that is older, the icon is filled with black, on stackoverflow I found such a solution that in the place where we insert the icon we specify tint . But this option did not help.
<corp.name.nameproject.customview.ItemMenuCustom
                android:id="@+id/im_event_board"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/padding_small"
                app:itmIcon="@drawable/ic_event_board_24dp"
                android:tint="@color/colorIcon"
                app:itmText="@string/event_board"/>

What needs to be done to fill the icon with the desired color on android below 5.0?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question