I read about app:srcCompat
on stackoverflow and also from other resources that the main purpose of this attribute is to support for vector-drawable. But I got confused when android:src
is also working fine with vector-drawable.
<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="#FF000000"
android:pathData="M10.18,9"/>
<path
android:fillColor="#FF000000"
android:pathData="M21,16v-2l-8,-5V3.5c0,-0.83 -0.67,-1.5 -1.5,-1.5S10,2.67 10,3.5V9l-8,5v2l8,-2.5V19l-2,1.5V22l3.5,-1 3.5,1v-1.5L13,19v-5.5l8,2.5z"/>
</vector>
I saved the above code in abc.xml
file in drawable directory, then I use it with android:src
<ImageView
android:id="@+id/imageView"
android:layout_width="300dp"
android:layout_height="300dp"
android:src="@drawable/abc" />
It is working fine. Then where app:srcCompat is helpful or is there any difference between them? or I understand it wrong?