Updated 23 December 2016
I stuck at a situation last week where I want to show a continuously animating background to my android application. The first option that stuck my head was the Animated .SVG files (For all of you wondering what it is you can have a look here). But after working on it for sometime I quit as my animation is quite impossible with animated .SVG, as I have to apply the animation to each and every element and my requirement was quite large too.
So after so much of effort I switch to a much easier way, which I probably do every-time, I moved to .gif. But as you know the android doesn’t have a view for applying .gif so I Google and found the library that can do it for me and the one suits my requirement. The library is android-gif-drawable. The library has its own custom views, in them if you pass a .gif they will show it in your android application. It is very simple just make your layout XML as
1 2 3 4 |
<pl.droidsonroids.gif.GifImageView android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/snowfall"/> |
The drawable snowfall.gif is present in the res/drawable folder. The library detects itself weather the drawable provided is a .gif file or any other file and then handles it accordingly.
Warning: GIF files are heavier so don’t try to send it via network as it can take forever to download. Also as they are heavier to load to it can cause the OutOfMemoryError on some devices. In my case the file is present inside the application and I made sure my activity takes lesser memory so that there would be enough space for GIF file to load. So test on different devices before using the library.
If you have more details or questions, you can reply to the received confirmation email.
Back to Home
Be the first to comment.