2

I have an ImageView in a RelativeLayout. The background of the ImageView is empty and the srcCompat is linked to my image in the drawable folder. In the layout Preview everything looks fine but when I test the app in an emulator or real smartphone my ImageView is empty and I can't see the selected Image. When I link the background property to my image in the drawable folder and delete the entry from srcCompat my picture is shown by the app. The problem is I can't scale the image if its set as the background of my ImageView. Can someone help me? Thanks and sorry for my bad english!

Yannik Pieper
  • 63
  • 1
  • 11

2 Answers2

2

The difference is that srcCompatis the actual content of your ImageView. You can, for example set backgroundColor to red, and give a drawable to your srcCompat. The result will be a red background and the given drawable above it.

Hope this helps.

Jefferson Tavares
  • 983
  • 1
  • 8
  • 23
0

Use src in place of srcCompat.As it srcCompat attribute is actually defined within AppCompat library. For more details

Community
  • 1
  • 1
Neelay Srivastava
  • 1,041
  • 3
  • 15
  • 46