Search code examples
androidimageviewpng

ImageView of PNG doesn't appear (maybe it's too big)


Inside my AlertDialog I've an ImageView, when I choose to show the android:src="@drawable/logo_small" (a png around 64x64px in every folders /hdpi /ldpi ect..) all works fine. Instead when I show android:src="@drawable/logo_big" (it's just ONE png of 1417x1417pixel and 593KB in the drawable root folder) the image doesn't appear.

The layout:

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center"
        android:orientation="vertical"
         >

        <ImageView
            android:id="@+id/imageLogoBig"
            android:layout_width="30dp"
            android:layout_height="30dp"
            android:adjustViewBounds="true"
            android:scaleType="fitCenter"
            android:src="@drawable/logo_big" />
    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:padding="5dp"
        android:src="@drawable/gplay_logo" />
    </LinearLayout>

The imageLogoBig doesn't show in the upper example and in the lower example:

<ImageView
    android:id="@+id/imageLogoBig"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:adjustViewBounds="true"
    android:scaleType="fitCenter"
    android:src="@drawable/logo_big" />

I just discovered while I was writing the question that if I delete from drawable root directory the image logo_big and if I copy it in drawable-hdpi, drawable-ldpi, drawable-mdpi and drawable-xhdpi, all works fine. And this is strange because the other image: imageView1, is only in the drawable folder (but is 172x60px) and is showed correctly.

Why is this happening? Any suggest? (For example put logo_big only in drawable-xhdpi...)


Solution

  • I solved moving logo_big png image only to the directory drawable-xhdpi, don't know really why, but it works now.