I have a gridview of images in my android app. It is an image gallery for an artist, so there are about 180 relatively high quality images in the resource folder. It works fine in the emulator and on my HTC Evo in debug mode. However when I publish it to the market and install it from there it crashes when the gridview is attempted to be loaded.
Is there a limit on locally defined images or is there a better way to manage so many images?
I went ahead and processed all the images into a worthwhile size for the respective
/res/drawable-hdpi (around 1000px wide or high)
/res/drawable-mdpi (max 300px)
/res/drawable-ldpi (max 75px)
and even though the compiled app is even bigger, it runs much better and does not crash on opening the gallery gridview.
Related
Hi There:) I am trying to create Image Gallery in Android, I am trying to load Thumbnails from HD images(more than 1000) from local device.
Glide.with(context)
.load(Uri.fromFile(new File(MyPhotoList.get(position).getPath()))).override(110,110)/*.thumbnail(0.1f)*/
.placeholder(R.color.colorAccent).into(holder.image);
But on scroll, RecycleView stucks and load image after few sec.(CPU: 70-80%, 180 MB, It consumes.)
(Test Device config. Deca-core 2.3 GHz, 4 Gb RAM).
Could you please suggest me, how to make smooth scrolling for image gallery.
I think this is normal behavior. On every another app launch (after the first one) glide will load those photos from its cache so it will be much smoothier.
To explain this just calculate, the phone needs to load e.g 20 photos those size together is about ~200/300 MB. Now take device's flash memory read speed. Most of devices may have about speed rate up to ~120 mb/s, so it means it may load those photos in few seconds.
Take a quick try with stock Gallery app on your phone. Open this and swipe down and see images and videos loading and compare with your app speed. Then you will know how big is difference againist those apps if any.
As I navigate through my NativeScript app, I keep running into out of memory crashes. I tried to resolve this by first upgrading {N} with #next for both tns-core-modules and tns-core-modules-widgets. I then installed nativescript-fresco and replaced all image tags with Fresco. It seems to of helped a bit but eventually if I navigate back and forth between a list view of images to another page, the app eventually crashes.
So I have a question regarding the usage of Fresco.
Let's say I have a bunch of images that is 1600 x 1200 and 1MB each.
And I use Fresco to display these images in a list view at thumbnail size like
100 x 100 square, does the app still load each of these images as a file size of 1MB each? Or does fresco create a thumbnail size and load a smaller file size version of the images?
I'm guessing that this maybe the reason why the app still crashes?
I'm developing an app and I got several HD Images (PNG Files) throughout the app. To navigate through the app as quickly as possible, I want to load all pictures in RAM and display them when the certain activity starts.
Means each activity has a HD picture.
Since it is quite impossible to load a 32bit HD Image to the RAM of the app, I had to resize them using that bitmap shit of Android. But I don't want to resize them.
Is it possible to load all HD images at the beginning of the app to the RAM? I don't understand why there are HD 3D games like Modern Combat 5 have no problems with that and just take the amount of RAM they need and I can't even load 7 or 8 HD Images at once to my app. Is there a trick? How can I get a Heap large enough for all my stuff to load at once and keep it in RAM while the app is active?
Thank you in advance
You need to recycle() your bitmaps after you complete the work with bitmap, so that will clear your memory :). Read this Displaying Bitmaps Efficiently
I've read "Supporting Multiple Screens" on the official docs.
I have around 15 activities. I currently have 4 background images. I've randomly assigned a background image to each of the screens in simple XML.
All these images are around 400X800 in the drawable hdpi folder.
Now the problem:
My app looks bad on tablets. The low resolution images are stretched out.. making them very blurry. So, I'm thinking about adding some higher res images.
The question:
So, now I have 4 images in the hdpi folder. (read slowly) ... If I add the same images of higher resolution in the xhdpi folder .... Will a device with screen of hdpi resolution also have to save the other res pics ?
I know that was confusing, below I explain with an example:
Okay, so I have three devices..
One small,
One medium,
One Tablet.
Now I have 3 sets of images in the mdpi, hdpi and xxhdpi.... for each of these.
Now, will the small device's apk file also contain the bigger images which are not used in it? ... I mean, can android choose which images it wants to download (changing the app size for different devices) ...?
Or does it simply download everything (increasing the app size)... and choose later on while running ?
The thing is, my app is like 800kb .... and adding 3-4 background images for large phones or tablets will drive up the app size to 5-6 mb... That's what I don't want.
So, are all the things stuffed in the apk downloaded equally on all phone sizes ? or are the pics downloaded selectively?
Do small phones unnecessarily download the big images too ?(vice-versa for tablets ?)
(I asked this question, because in many android apps , their size says "Variable for different devices" or something like that... and there's no mention of this whatsover, anywhere on the internet. Trust me, I googled for an hour.)
Yes. Your project size will increases whatever images added in all folders. If you are designing for 4 different screen your apk size will increase automatically. If you want any images common for all screens, then you can create a drawable folder and place the image in it. So it will pick automatically. Both apk size and your project quality are important. So you should consider image size when adding to the project. By using padding and other xml factors you can adjust screen size by same image also.
The whole apk is downloaded together with all images for all resolutions. As you usually upload only one file to Google Play, the same file is downloaded by everyone.
There is an option do distribute different apk files based on device onfiguration but it is not very convenient to manage.
You can read about publishing multiple apk in here: http://developer.android.com/google/play/publishing/multiple-apks.html
I'm writing a program about letters for babies and I'm using 28 images. It's a flashcard program, and was running ok until I reached 20 images.
It force-closes before opening. I'm still in my early stage in the program. I put my images in the drawable-mdpi. After working on this error for 2 days, I discovered that when I split the images between drawable-mdpi and drawable-hdpi it works well, but the images that are in the hdpi folder are smaller, although they are of the same size.
I want to know, why does it work when splitting the images? Is there a limit to the number of images per folder? And also, why do images that are in the hdpi folder get smaller in the app?
There is no limit of the number of images per folder. I have an application with more than 360 pictures in the folder drawable-mdpi (really) for a total size of 32Mb and it works well.
If you test your application on a mdpi screen (160dpi), and you had hdpi images (for 240dpi), then the application automatically reduces them at run time by multiplying their size by a factor 160/240 = 0.66, which explains why they appear smaller.
See Multiple screen support for Android for more information.
The dpi are the "Dots Per Inch", Android allows a simple way to ensure that the Device running the application will load the best available resources, for its "bucket", the category of dpi it uses.
You can disable this behavior, by creating another drawable folder (such as res\drawable-nodpi), and place your bitmaps there, and then loading then, and doing any mutation as needed.