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?
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With