I want to create a custom, complicated loading graphic for my Android App (minSDK 8).
If I create a GIF with 100 frames, is there a way in Java/Android to tell it which frame to go to during my 'doProgress()' function?
Is there another or better way to do custom loading graphics?
If I create a GIF with 100 frames, is there a way in Java/Android to tell it which frame to go to during my 'doProgress()' function?
Since Android does not do animated GIFs, no.
Is there another or better way to do custom loading graphics?
Option #1: Use a frame animation.
Option #2: Use a RotateAnimation with a single image in an ImageView.
Option #3: Use ViewPropertyAnimator (using NineOldAndroids for the backport) to animate android:rotation with a single image in an ImageView.
There may be other options as well, though those are the three that come to mind.
If you have a gif image, then you can use WebView component to show the gif image. In webview, the image loops itself, we do not need to do extra work.
Related
Given:
A number of images (10 - 15) residing in assets folder (as practice shows, the better approach is to keep high-resolution images in assets)
Android UI thread (caching drawables in advance is already made in a background thread)
The issue:
Need to display all the images one on another smoothly and not blocking UI thread after the images are drawn.
Already used approaches:
Dynamically create a required number of ImageView and then call .setImageDrawable(). This takes a lot of time but the worst thing is that the UI thread is being blocked even after all the images are drawn on their ImageView.
Create a LayerDrawable object and pass as argument an array of the required Drawables. Then put it on an ImageView also by calling .setImageDrawable(). This option behaves the same like the one described above.
Is there a way to solve this issue? Or Android devices not capable to cope with it?
Try Picasso library:
http://square.github.io/picasso/
It has support for resources:
Picasso.with(context).load(R.drawable.landing_screen).into(imageView1);
Picasso.with(context).load("file:///android_asset/DvpvklR.png").into(imageView2);
Picasso.with(context).load(new File(...)).into(imageView3);
If you are requiring a smooth transition between images, please try viewFlipper
https://developer.android.com/reference/android/widget/ViewFlipper.html
Basically you can add imageView inside the viewflipper and start animation to move from previous to next image. I am not sure if you need user interactions like scrolling or not. You can try viewPager if user need to scroll betweens images.
Please note that Glide does provide some transition effects for switching between placeholder and image to display. But transition between images are not included, you can have a look here
http://bumptech.github.io/glide/doc/transitions.html
I hope this helps because i am not sured that if you are asking the transition between images or rendering images.
I'm using Fresco to load and display GIF and WEBP for my app.
I have a Gridlayout where I display a list of GIF and WEBP. Images are animating as intented but one thing I notice is that they are not animated at the same time. Some images wait for the other to finish animating before it starts its own animation which is not the way I expect it to be.
Does anyone experienced this before? How to fix it?
This should work out-of-the-box.
Take a look at the animation sample app, where we have 2 animations in parallel (and they animate at the same time).
I'm working on an application in which I need to download lots of images. The images are to be seen in the fullscreen mode. Therefore, I wanted to know how to load an image, speedily, to make the application more responsive and enhance user experience. I would like to, atleast, show a blurred image first and than make it sharp. Thanks.
use BitmapFactory.Options.inSamleSize to load a downsampled version of the image. Then load the bigger image and do a fade transition using a TransitionDrawable
You're looking for "progressive image rendering", which can be done in a variety of different image formats, including png, jpeg, gif, etc. The next time you're going to save an image in a good graphics program, select one of those formats and take a look at your save options. You should have an option to save an "interlaced" image.
Jeff Atwood of Coding Horror has a nice write up here: http://www.codinghorror.com/blog/2005/12/progressive-image-rendering.html
Example Images
Would implementing these into an android app as an ImageView be the same as implementing a regular image, or would problem, low performance occur since they are .GIFs?
I am aware that .PNGs are the go to image for android so is it possible to create animated .PNG images, if not what is the best practice for including animated images?
First, PNG's can't be animated. From bitmap formats, only GIF supports animation. Unfortunately Android doesn't support animated gifs.
Read also this: Display Animated GIF
You may use AnimationDrawable to display animated set of images. However, such storing of animation frame by frame is taking much more memory than typical animated gif.
There's no easy solution for displaying animated gif on Android at present.
I want to create my own sprite sheet from a single image i have by modifying the image(like changing the position of the leg).For example lets say i have an image of a man running.I want to create a sprite sheet from this single image.What software do i use for this.From want i understand texturepacker and other such softwares enable you to edit the spritesheet.But as of now i have no images in the sprite sheet except for one.
Another question i had was that lets say i want to create my own sprites,how do i do this.(Are there softwares available for this)
There is simple program to create spritesheets from swf animation, SWFSheet, written by Keith Peters. Animation can be created in Flash or any 2d animation editor which supports export to swf like KToon, SWF Quicker, Giotto and so on.
And maybe single-framed bitmap can be animated using morphing?