0

My issue is that, when I add an ImageView using the "Pick a Resource" tool, the image is shown in the layout of the activity in Android Studio. but when I execute it on my phone which is Huawei Y7 Prime. It doesn't show at all.

I tried many solutions that are proposed in other questions step by step but any of them didn't seem to work.

  1. Tried to use android.support.v7.widget.AppCompatImageView instead of ImageView but it seems that the android studio doesn't recognize it. I set all steps in this question... But -> not working!.
  2. I used android:src instead of app:srcCompat like it says in this one -> not working!.
  3. I Set a line of code like this android:hardwareAccelerated="false" in AndroidManifest.xml file in the Application tag -> not working either!.
  4. Used src instead of srcCompat like this one

I used a very basic code to set the ImageView

<ImageView
        android:id="@+id/imageView3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        tools:srcCompat="@tools:sample/backgrounds/scenic" />

I Used The LayoutInspector tool to see if the image is showing. I found that it's not.

Please Anyone can help??

Slimane
  • 3
  • 3

1 Answers1

1

Instead of using tools:srcCompat, you should use android:src.

The tools namespace is used for debug purposes, that's why it's visible in AndroidStudio but not in actual device.

Also, make sure your source uses the valid reference (or one from android). For example:

android:src="@drawable/your_image"
waqaslam
  • 67,549
  • 16
  • 165
  • 178