Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android ImageView not loaded

I am using the android imageView and I put the the image into the drawable folder, and changed the imageView source to that image. But it does not show the image in the Preview panel and when I open the picture in the android studio,it show the error like this.

But I can open the picture on my computer desktop. so why there is the error and how to solve it?

like image 539
xiaoyun Avatar asked Mar 04 '16 13:03

xiaoyun


People also ask

Why image is not showing in ImageView Android?

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. As someone already mentioned it would be good to take a look at your code.

What is Android ImageView?

ImageView class is used to display any kind of image resource in the android application either it can be android. graphics. Bitmap or android. graphics. drawable.

What is adjustViewBounds?

When using adjustViewBounds you need to set either width or height of your image view to wrap content and the other to a fixed value. Then when you set adjustViewBounds to true, Android adjust your image based on the fixed height or width value you've set and keeps aspect ratio. The scale type plays also a role.


1 Answers

Sounds like piac.png was not a .png file, you just slapped a .png extension on it and expected it to become a .png file. The problem is likely resolved by opening the file (maybe it was a .jpg) and then saving it as an actual .png file.

like image 64
A. T. King Avatar answered Nov 08 '22 10:11

A. T. King