Home > Software design >  Android studio: why image shown in design disapears in run time?
Android studio: why image shown in design disapears in run time?

Time:08-18

Images shown in Android studio disapear in the emulator : More than words, you can see thus screenshot explicit:

Code:

<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"

    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/signorGrey">

    <ImageView
        android:id="@ id/logoSignor"
        android:layout_width="65dp"
        android:layout_height="77dp"
        app:srcCompat="@drawable/iconpetit2929"
        android:gravity="start|center_vertical"
        android:background="@color/signorBlue"
        android:visibility="visible"
        android:contentDescription="@string/logosignor"/>

Do you know why ?

CodePudding user response:

Check your logcat you maybe getting some error like "bitmap too large" if that so your image can not be implemented try to change the width and height of image

CodePudding user response:

I had this problem before and as a solution, I solved the path of the photo by using src instead of srcCompat. I suggest you use it like this;

<ImageView
                    android:id="@ id/logoSignor"
                    android:layout_width="65dp"
                    android:layout_height="77dp"
                    android:src="@drawable/iconpetit2929"
                    android:gravity="start|center_vertical"
                    android:background="@color/signorBlue"
                    android:visibility="visible"
                    android:contentDescription="@string/logosignor"/>
  • Related