Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android ImageView Is Not Displaying Image?

Can anyone tell me why the following code is not working? The Image does not appear at all.

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

   <ImageView
          android:src="@drawable/splashscreen"
          android:scaleType="center"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content" />

</RelativeLayout>
like image 263
comead Avatar asked Mar 21 '12 03:03

comead


People also ask

Why my image view is not showing in Android Studio?

First : Check if you have added your image source to your xml layout. If you have added an image in the corresponding activity code , then the image will not appear in your xml layout.

What is adjustViewBounds in Android?

android:adjustViewBounds—If set to true, the attribute adjusts the bounds of the ImageView control to maintain the aspect ratio of the image displayed through it.


2 Answers

In my case, all my fragment's imageViews are not showing when I run my application. The problem is, I extend my "Activity" class from "FragmentActivity". so I just change it "FragmentActivity" to "AppCompatActivity"

maybe this will help someone.

like image 123
bst91 Avatar answered Oct 22 '22 03:10

bst91


In ImageView there is two options src and srcCompact. Try both of them to find out which is working.

android:src="@drawable/slide_view_4"

and

app:srcCompat="@drawable/slide_view_4"
like image 33
Sasindu Lakshitha Avatar answered Oct 22 '22 04:10

Sasindu Lakshitha