0

when I make SVG file in victor asset and make it as drawable for editText it looks Too Large, I saw many videos they create new victor asset and choose the "SVG" file and it makes it as "XML" file and I make drawableStart For EditText but it Too Large not Like The Videos I make all Steps but it always Fails.

This is what its look like:

enter image description here

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".ListView">


  <EditText
    android:id="@+id/editText"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="#17FFFFFF"
    android:drawableStart="@drawable/ic_search"
    android:drawableLeft="@drawable/ic_search"
    android:ems="10"
    android:inputType="textPersonName"
    android:textSize="32dp" />

</LinearLayout>

SVG

<vector
    android:alpha="0.85"
    android:autoMirrored="true"
    android:height="512.005dp"
    android:viewportHeight="512.005"
    android:viewportWidth="512.005"
    android:width="512.005dp"
    xmlns:android="http://schemas.android.com/apk/res/android">
    <path
       android:fillColor="#FF000000"
       android:pathData="M505.749,475.587l-145.6,-145.6c28.203,-34.837 45.184,-79.104 45.184,-127.317c0,-111.744 -90.923,-202.667 -202.667,-202.667S0,90.925 0,202.669s90.923,202.667 202.667,202.667c48.213,0 92.48,-16.981 127.317,-45.184l145.6,145.6c4.16,4.16 9.621,6.251 15.083,6.251s10.923,-2.091 15.083,-6.251C514.091,497.411 514.091,483.928 505.749,475.587zM202.667,362.669c-88.235,0 -160,-71.765 -160,-160s71.765,-160 160,-160s160,71.765 160,160S290.901,362.669 202.667,362.669z"/>
</vector>
Muhammad Farhan
  • 1,113
  • 10
  • 22

2 Answers2

3

change these two lines of svg xml. From

android:height="512.005dp"
android:width="512.005dp"

To

android:height="24dp"
android:width="24dp"

You can manage svg size according to EditText size

Rupesh Rathore
  • 319
  • 1
  • 9
1

Resize your vector to 24dp which is default size of any icon in android studio. Change the size when your importing.

<vector
android:alpha="0.85"
android:autoMirrored="true"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0"
android:width="24dp"
xmlns:android="http://schemas.android.com/apk/res/android">
<path
   android:fillColor="#FF000000"
   android:pathData="M505.749,475.587l-145.6,-145.6c28.203,-34.837 45.184,-79.104 45.184,-127.317c0,-111.744 -90.923,-202.667 -202.667,-202.667S0,90.925 0,202.669s90.923,202.667 202.667,202.667c48.213,0 92.48,-16.981 127.317,-45.184l145.6,145.6c4.16,4.16 9.621,6.251 15.083,6.251s10.923,-2.091 15.083,-6.251C514.091,497.411 514.091,483.928 505.749,475.587zM202.667,362.669c-88.235,0 -160,-71.765 -160,-160s71.765,-160 160,-160s160,71.765 160,160S290.901,362.669 202.667,362.669z"/>

Nikesh Nayak
  • 302
  • 2
  • 9