Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![codeoverload](https://uploads.teamtreehouse.com/production/profile-photos/6911452/micro_Screenshot_20170408-205557-01.jpg)
codeoverload
24,260 PointsIs there a difference between android:src and app:srcCompat?
When should I use one over the other for an ImageView
?
1 Answer
![Kyle Baker](https://secure.gravatar.com/avatar/bb52e30e7d3577778c9dc43c8d6abe5c?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Kyle Baker
8,211 PointsFrom what I've gathered, seems the difference is that app:srcCompat is an attribute used when you want a vector drawable (vector images can be resized without losing image quality where png files lose image quality). Android:src would be the attribute for you if you were to go with a png drawable. You can use these attributes on ImageButtons and ImageViews (maybe more, but at least those two).
I used this link if you want to check it out http://android-developers.blogspot.com/2016/02/android-support-library-232.html
codeoverload
24,260 Pointscodeoverload
24,260 PointsMakes sense, but I used a png file and Android Studio automatically chose app:srcCompat...strange. I looked again on some other sites and here (https://medium.com/@chrisbanes/appcompat-v23-2-age-of-the-vectors-91cbafa87c88#.pf6wmj3oz) it says (as you said) that srcCompat was introduced because of vector graphics. Maybe you can still use it for pngs but it provides some new functionality for vectors.
Thanks for your answer anyway!
Kyle Baker
8,211 PointsKyle Baker
8,211 PointsNp and thanks for sharing the bit about being able to use pngs with it