Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Increase VectorDrawable icon stroke in xml

I have some svg icons for my android project. How to increase stroke-width of these icons.

One icon xml as example:

<vector android:height="28dp" android:viewportHeight="58.365"
    android:viewportWidth="58.365" android:width="28dp" xmlns:android="http://schemas.android.com/apk/res/android">
    <path android:fillColor="#000000"  android:pathData="M57.2641,26.6852l-8.4997,-7.8927L48.7644,5.8623l-9.7912,0l0,3.8391L29.182,0.6093L1.1008,26.6852c-0.3956,0.3681 -0.4191,0.9879 -0.0509,1.3845c0.3672,0.3956 0.987,0.4181 1.3845,0.0509l3.2497,-3.0176l0,32.6527l15.6659,0l15.6659,0l15.6659,0L52.6819,25.102l3.2497,3.0176c0.188,0.1753 0.4279,0.2614 0.6668,0.2614c0.2634,0 0.5248,-0.1048 0.7167,-0.3123C57.6832,27.6732 57.6597,27.0534 57.2641,26.6852zM40.9314,7.8205l5.8747,0l0,9.1538l-5.8747,-5.4547L40.9314,7.8205zM23.3073,55.7974L23.3073,35.1742c0,-0.5062 0.4112,-0.9174 0.9174,-0.9174l9.9146,0c0.5062,0 0.9174,0.4112 0.9174,0.9174l0,20.6232L23.3073,55.7974zM50.7226,55.7974l-13.7077,0L37.015,35.1742c0,-1.5862 -1.2895,-2.8757 -2.8757,-2.8757L24.2247,32.2985c-1.5862,0 -2.8757,1.2895 -2.8757,2.8757l0,20.6232l-13.7077,0L7.6414,23.2838l21.5406,-20.0024l13.9818,12.9831l5.6006,5.2001l0,0l1.9582,1.8182L50.7226,55.7974z"/>
</vector>
like image 419
Zubayr Avatar asked Sep 28 '18 08:09

Zubayr


People also ask

What is VectorDrawable?

A VectorDrawable is a vector graphic defined in an XML file as a set of points, lines, and curves along with its associated color information. The major advantage of using a vector drawable is image scalability.

Is SVG compatible with Android?

Android Studio includes a tool called Vector Asset Studio that helps you add material icons and import Scalable Vector Graphic (SVG) and Adobe Photoshop Document (PSD) files into your project as vector drawable resources.

What is Android path data?

PathData in vector images android is Vector graphic program's script. It is not exactly clean and human readable code as a high priority.


2 Answers

Please try below code

<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="28dp"
    android:height="28dp"
    android:viewportWidth="58.365"
    android:viewportHeight="58.365">
    <path
        android:fillColor="#000000"
        android:strokeWidth="1"
        android:strokeColor="#000000"
        android:pathData="M57.2641,26.6852l-8.4997,-7.8927L48.7644,5.8623l-9.7912,0l0,3.8391L29.182,0.6093L1.1008,26.6852c-0.3956,0.3681 -0.4191,0.9879 -0.0509,1.3845c0.3672,0.3956 0.987,0.4181 1.3845,0.0509l3.2497,-3.0176l0,32.6527l15.6659,0l15.6659,0l15.6659,0L52.6819,25.102l3.2497,3.0176c0.188,0.1753 0.4279,0.2614 0.6668,0.2614c0.2634,0 0.5248,-0.1048 0.7167,-0.3123C57.6832,27.6732 57.6597,27.0534 57.2641,26.6852zM40.9314,7.8205l5.8747,0l0,9.1538l-5.8747,-5.4547L40.9314,7.8205zM23.3073,55.7974L23.3073,35.1742c0,-0.5062 0.4112,-0.9174 0.9174,-0.9174l9.9146,0c0.5062,0 0.9174,0.4112 0.9174,0.9174l0,20.6232L23.3073,55.7974zM50.7226,55.7974l-13.7077,0L37.015,35.1742c0,-1.5862 -1.2895,-2.8757 -2.8757,-2.8757L24.2247,32.2985c-1.5862,0 -2.8757,1.2895 -2.8757,2.8757l0,20.6232l-13.7077,0L7.6414,23.2838l21.5406,-20.0024l13.9818,12.9831l5.6006,5.2001l0,0l1.9582,1.8182L50.7226,55.7974z" />
</vector>
like image 77
Rujul Gandhi Avatar answered Sep 24 '22 01:09

Rujul Gandhi


as simple as adding these two fields to path tag

android:strokeColor="@color/red"
android:strokeWidth="1"
like image 23
Mohamad Rostami Avatar answered Sep 23 '22 01:09

Mohamad Rostami