Imageview is not showing my image?

时间:2016-02-12 19:41:09

标签: java android android-layout imageview drawable

My image shows on Android Studio itself, but when uploading to my phone the image is gone. Maybe it's a too big image? It's 1900 x 1250 pixels.

I have no idea what I'm doing wrong..

enter image description here

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="About"
    android:id="@+id/button"
    android:layout_alignParentTop="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:backgroundTint="#fed136" />

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Portfolio"
    android:id="@+id/button3"
    android:backgroundTint="#fed136"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true" />

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Contact"
    android:id="@+id/button4"
    android:layout_alignBottom="@+id/button3"
    android:layout_alignParentRight="true"
    android:layout_alignParentEnd="true"
    android:backgroundTint="#fed136" />

<ImageView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:id="@+id/imageView"
    android:layout_below="@+id/button3"
    android:scaleType="fitXY"
    android:src="@drawable/header" />

2 个答案:

答案 0 :(得分:1)

I could not place a comment, but try to look for the image view in your activity. It could be because your code is overriding it from there.

also limit the size of your imageview from the layout xml to make sure its loaded correctly.

And from experience with large photos, they normally not loaded easily on an emulator. so try smaller image as a last step.

答案 1 :(得分:1)

Yes, the layout looks okay. Try to place the image in drawable-xxxhdpi folder. Create a folder inside your res folder and name it drawable-xxhdpi if its not there. Place the large image inside this folder and check if that helps.

If not, please resize your image as this is the only problem you've here I guess. Too large image causes out of memory error in low-end devices.