Background image not showing -Android - android

I have written a Catching Fire Countdown app that has a background image. I had the image placed in all Drawable folders. I removed them so the file wasn't so large and I received complaints that the image no longer showed. I put the images back, the app updated, and I'm still being told that the picture isn't showing up on certain devices. Nexus 7 is one of them and Galaxy tab II are the 2 recent ones I've heard about. Instead of my image it is just a black background.
Any idea why? How can I get an image to display on EVERY device?
I was reading something about tablets, the image, and it being a possible out of memory thing? Does that sound familiar to anyone?

Put your set of image in every following folder
**drawable-mdpi
drawable-ldpi
drawable-hdpi
drawable-xhdpi**
After looking into drawable-mdpi,drawable-ldpi,drawable-hdpi,drawable-xhdpi.Last place where the Android OS looks for the Image if it is unable to find that image, is the drawable folder So try placing the image in it also and see if it works.

Related

Where to store images in Android

I have moved all my images from the folder mipmap to drawable because here it was said that the mipmap folder is only for app icons to lanch the app Mipmaps vs. drawable folders (the answer got 841 likes). However, when I now want to start my app I get an error message
FATAL EXCEPTION: main
Process: com.example.td.barapp, PID: 4331
java.lang.RuntimeException: Canvas: trying to draw too large(188394348bytes) bitmap.
at android.view.DisplayListCanvas.throwIfCannotDraw(DisplayListCanvas.java:260)
In several realted questions people tell to store the pictures in different drawable folders (see Android : Understanding drawable folder) like drawable-xxhdpi or drawable-xxxhdpi.
Update: I was told by someone in this post (who later deleted his answers) to store the image (which has a size of 1,7 MB) in the folder drawable-anydpi. I did as he said but the outcome on the Emulator looks quite bad for an imageview (see screenshot):
Then I moved the same file back into the folder mipmap-xxxhdpi and now it looks good again. So my question now is, whether it is also okay to have the image in the mipmap-xxxhdpi folder instead of the drawable folder? I'd be happy for every advice because I am quite confused now.
java.lang.RuntimeException: Canvas: trying to draw too
large(188394348bytes) bitmap
This exception mainly because you are trying to display a big image ~ 188MB which will have a high resolution, and android puts limitation on that, This also reported here.
One of the reasons is to save device resources; for instance you might get java.lang.OutOfMemory, so the system save device memory from that.
1, 2, 3 may guide you thoroughly on that.
Normally you can use a few mega bytes image in your app ~0-3MBs.
Third party libraries like Glide & Picasso offer disk, network, & memory management techniques while displaying images on your ImageViews.
One of the options you may consider is to resize images before loading them, so can have look on this question.
Keep in mind that android puts limitaion on your apk file on the app store, so you need to minimize images for that reason, or load them from a back-end server.
As you mentioned, you can only put app icons in res\mipmap. And if you decide to put the images on your app, it's efficient to create them in different densities (hdpi, xhdpi, xxhdpi, xxxhdpi...), so they can match all the variety of device resolutions, and lets you avoid distorted images or high processing by android OS to match your image to the device resolution before displaying them.

Localized drawable folder not always works

Localized drawable folders works like this that phone searchs for a images in specific folder (in example drawable-sw720p) and if there is nothing it needs right now it searchs in normal drawable folder, right?
I have few images dedicated to tables. So, I need 4 drawable folders (sw600dp, sw720dp, xxhdpi, xhdpi also). And it should works fine, but - in these 4 folders I have the same image (multiplied by amount of different images), so in the end my app is a little bit too heavy.
Now my problem: some time ago I tested my other app on my friend's phone and I realized that his phone doesn't take images from drawable folder (it only takes images from it's folder like drawable-mdpi). So, I had to put all the images into drawable-mdpi and to others drawables event if some images are exactly the same.
So, now I want to minimalize my app size by putting all same events into the standard drawable folder and to localized folders only the ones which are different - but I'm scared of the situation I wrote about.
Is there any way to solve this problem? Or no and I just should copy the same images into every drawable folder I have?
Please let me know, I'm sure someone here knows the best practise to make it lighter and works just fine on all the phones (including dumb ones like my friend's) ;)

In Android Studio poor ImageButton quality

Ok I am creating an android app I have it all done the problem is a company wants me to use their logo on the ImageButton in the app. The problem is no matter what quality the image starts at and it doesn't matter if it is a 9 patch or just a png the image looks very pixelated unless it is very tiny which then means you can't see it when you run the app. I have looked and looked and every thing I have come across so far doesn't help.
Here is an example I am just using a pic off my computer as an example this ^^^^^ is the orignial.
Here is after hard to tell with out enlarging the picture it has to do with stretching to fit the background of the app or image button.

Android Images have trouble loading after firing off lots of activities?

I have a simple app that displays a series of images and infomation about those images. I've set it up so that when a user touches an image, a new activity is launched and they see more pictures and a longer text description about that image. On that screen, I've also implemented the basic gallery widget that they have here in the Hello Gallery Tutorial.
My problem is that even though I'm drawing on images from the res directory (I've thrown everything in drawable-mdpi thinking that there shouldn't be a huge deal), not all of the images on the gallery portion will load. And I haven't been able to reproduce it 100%, but it seems like the more I play with my phone with this app running (lock screen, unlock screen, go to one image, go back, go to another one, hit home, etc), the more likely any picture that I've got loaded up locally display blank image placeholders, gallery or not (the text comes up fine though).
I'm using a series of imagebuttons, imageviews, and gallery widgets. Play with it enough and eventually they all come as blank, but killing everything through AdvancedTaskKiller brings it back.
Sometimes pictures in my image galleries will also be blank when I first launch my app. That's really weird. I have it set so that the layoutparams are 300 by 200 and I've pulled pictures all over the place to populate my gallery. They should just all scale differently, not fail to load entirely though.
Anybody have any ideas on these?
Try Slow Adapter for the Gallery.
I recommend adopting 1,2,3
It is always hard to work with images. You have to be very careful with recycling memory that your images already used otherwise you could get into different kind of troubles.
Always try to use a good Image loading library that commonly being used by Android developers.
Most commonly used library is https://github.com/nostra13/Android-Universal-Image-Loader
It will optimise your loading.

Problem with wallpaper app

I have a wallpaper app and it seems to work fine but... when i open the app in eclipse... the app icon appears as the first image in the wallpaper. I cannot figure out what is happening. can someone help.
also the scrolling seemed to have slowed down after i added more images (40)..any suggestions. what is the recommended file size the files papers should be. I know the dimensions but what about the resolution.
The resolution isn't relevant if you already know the dimensions (if I'm understanding you correctly). For the Droid, you need 960 x 854 pixel images. When I hear resolution, I think dpi/ppi.
As far as the app icon appearing in the list...you should post some code as to how you're listing the images. Are you just populating them from the #drawables folder? That's where your app icon is stored, too.

Categories

Resources