I'm trying to insert an animation in my app and I found two alternatives:
the first one is to use the "Drawable Animation" with the "animation-list", but my animation is made of 125 full screen frames and when I tried to start it the app crashed with the "java.lang.OutOfMemoryError".
I tried to fix the problem increasing the heap size by setting the android:largeheap="true" but didn't work.
Is a possible solution converting the images from jpg to png?
I found the solution here java.lang.OutOfMemoryError occur on the animation Loading? and something here Causing OutOfMemoryError in Frame by Frame Animation in Android, but I didn't find a correct solution.
The second way is to create the animation in javascript/html5 and putting it in a webview, but I don't know if this would be a good solution for the majority of android devices and I don't know if it is possible create a communication bridge between the webview and the app.
I found this http://developer.android.com/guide/webapps/webview.html#BindingJavaScript but I'm not sure if it will work.
So could you please give some idea on finding a way for complex animation in android?
Related
I am trying to rotate really large bitmaps inside android like 3000x5000 px with
matrix.postRotate()
but the problem is that this procedure despite the fact that it is very common inside android and it is working properly...it is slow for such large bitmaps...almost 5 seconds on my phone. Due to project limitations, resizing it is not an option here. Does anyone has another suggestion for faster rotation?
I am using CameraX and onImageSavedCallback.
Thanks in advance.
this question is a general question.I just wanted to know if there is any way through.I am having a very low refresh rate display android device due to which all the animations are getting lagged.I am needing a scaling animation which shrinks and grows of which i am having code but the issue is the smoothness.Is there any possible way that i can make my animation smoother for scaling animation or any way which shows like the animation appears smoother?>
Thanks in advance.
I have faced a similar issue with abrupt animations. Actually, the problem is not with the refresh rate of the device, the application might not be using the full hardware capabilities of the Android device, so not much can really be done
Also add the following line in the application tag of the manifest android:hardwareAccelerated="true" to ensure HW acceleration is used
I am new to Android and I having troubles setting a dynamic background just like Tumblr login UI,
The link below is where I got some help.
Set Animated .GIF As Background Android
But it only works when I load small-size animation, or I have to drop lots of frames of a GIF animation which leads to incoherence.
If I load all the frames which will cause OutOfMemoryError, I don't think it's the right way.
Is tumblr uses GIF animation or it's actually a short video?
I know that Twitter converts all GIFs to MP4. Video compression is far better than GIFs leading to smoother playback and reduced bandwidth and happy users :) Is using MP4s an option?
More on the subject here.
Not sure how long your animation is, or how high res its frames are, but you probably need to look at loading the image frames in scaled down form into memory. The Android docs give a very coherent explanation of how to do this here (basically, you first find the res of the bitmap, then load a scaled down version of it appropriate to the device's screen resolution). It may also be that the animation is too long, and you need to look at forcing bitmaps to recycle (using bitmap.recycle()) once displayed.
So I am building a rather complicated budget management application. I am still struggling with this problem though. I have seen apps like Yahoo!Weather utilizing huge high-resolution images as their activity backgrounds and their app runs smoothly. However when I assign an image file as an android:background to a View this makes the application lag out like nothing else. What is the way to work around this? (I assume there is one.)
Thank you in advance!
So we know about this two ways of implementing animations on Android
I couldn't find any performance difference if there are any..
I am aware that frames will make apk file bigger (picture for each frame), and that with tween you need/can precisely to define animation, but which way of animating is from memory/cpu consumption side more efficient? Any clue?
Thanks