Android Animated GIF Image Example
Below i added code for How To display animated GIF image in Layout. display animated GIF image in your application splash page or else any where.
Xml Code
-->
-->
-->
Below i added code for How To display animated GIF image in Layout. display animated GIF image in your application splash page or else any where.
Xml Code
-->
<?xml
version="1.0"
encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent"
>
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textColor="#ACC437"
android:textStyle="bold"
android:text="WelCome
To This Blog"
android:textAppearance="?android:attr/textAppearanceLarge"
/>
<com.androidqa.AnimationView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>
Screen Shot
Activity Code
-->
/**
*
@author
vijayakumar
*/
import
android.app.Activity;
import
android.os.Bundle;
public
class
AndroidQAActivity extends
Activity {
@Override
protected
void
onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
View Class
-->
/**
*
@author
vijayakumar
*/
import
java.io.ByteArrayOutputStream;
import
java.io.InputStream;
import
android.content.Context;
import
android.graphics.Canvas;
import
android.graphics.Movie;
import
android.util.AttributeSet;
import
android.util.Log;
import
android.view.View;
public
class
AnimationView extends
View {
private
Movie mMovie;
private
long
mMovieStart;
private
static
final
boolean
DECODE_STREAM
= true;
private
static
byte[]
streamToBytes(InputStream is) {
ByteArrayOutputStream os = new
ByteArrayOutputStream(1024);
byte[]
buffer = new
byte[1024];
int
len;
try
{
while
((len = is.read(buffer)) >= 0) {
os.write(buffer, 0, len);
}
} catch
(java.io.IOException e) {
}
return
os.toByteArray();
}
public
AnimationView(Context context,AttributeSet attrs) {
super(context,attrs);
setFocusable(true);
java.io.InputStream is;
// YOUR GIF IMAGE Here
// YOUR GIF IMAGE Here
is =
context.getResources().openRawResource(R.drawable.th_welcome);
if
(DECODE_STREAM)
{
mMovie
= Movie.decodeStream(is);
} else
{
byte[]
array = streamToBytes(is);
mMovie
= Movie.decodeByteArray(array,
0, array.length);
}
}
@Override
public
void
onDraw(Canvas canvas) {
long
now = android.os.SystemClock.uptimeMillis();
if
(mMovieStart
== 0) { // first time
mMovieStart
= now;
}
if
(mMovie !=
null)
{
int
dur = mMovie.duration();
if
(dur == 0) {
dur = 3000;
}
int
relTime = (int)
((now - mMovieStart)
% dur);
Log.d("",
"real time :: "
+relTime);
mMovie.setTime(relTime);
mMovie.draw(canvas,
getWidth() - 200, getHeight()-200);
invalidate();
}
}
}
Please Leave the FeedBack
Nice Job ....
ReplyDeleteDOWNLAOD FULL SOURCE CODE is not working give me the full source code
ReplyDeleteHello Career Info .
ReplyDeleteI uploaded source code different server. now can able to download.
Very usefull.... Thank you.
ReplyDeletehow can i do it for large image
ReplyDeletehow we can add animation into gridview
ReplyDeleteThank you so much.. it is working f9 :)
ReplyDeleteHello mates, how is all, and what you wish for to say regarding
ReplyDeletethis article, in my view its actually amazing in support of me.
My weblog - Joel
I really love your site.. Great colors & theme.
ReplyDeleteDid you create this web site yourself? Please reply
back as I'm trying to create my very own website and would love to find out where you got this from or just what the theme is named. Appreciate it!
Here is my web site :: ipad training program
Hi there, I discovered your web site by way of Google while looking for a related matter, your web site came
ReplyDeleteup, it appears good. I've bookmarked it in my google bookmarks.
Hi there, just was alert to your weblog via Google, and found that it is truly informative. I'm going to watch out for brussels.
I will appreciate for those who continue this in future.
Lots of other people might be benefited out of your writing.
Cheers!
Here is my weblog : Heaven
Excellent beat ! I wish to apprentice while you amend your web site, how can
ReplyDeletei subscribe for a blog web site? The account helped me a acceptable deal.
I had been a little bit acquainted of this your broadcast offered
bright clear idea
Here is my web-site ; gryonline.me
Nice job , ty so much :cheer:
ReplyDeletevery nice.
ReplyDeleteThis comment has been removed by the author.
ReplyDeletenice work.... thanks a lot
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteProject 'AndroidQAActivity' is missing required library: '\home\vijayakumar\Downloads\android-sdk-linux\platforms\android-11\android.jar' AndroidQAActivity Build path Build Path Problem
ReplyDeleteI am getting this error how can i correct this error
Hi,
DeleteIn Eclipse , Windows -> show View -> Problems
Delete the Errors , what you have .
Thanks
when i preview Show View,there is no problem,how are we suppose to change to library?
DeleteGo to Project -> Prop. In Java Build Path, Delete tht android.jar (home\vijayakumar\Downloads\android-sdk-linux\platforms\android-11\android.jar')in Libraries tab.
DeleteThn Click Add External Jars, and include from ur android sdk -> platforms -> android-7 -> android.jar.
Thts all.
hi, the code work but why the gif does animate?
ReplyDeleteHi ,when i download this code it's working.but when i try this code use in other app it not showing gif image, it change the package name in XML also, then also it not showing not crashing also ,plz help me
ReplyDeleteThis comment has been removed by the author.
ReplyDeletei cant download ur source code..................
ReplyDeleteThey found that colostrum significantly inhibited nuclear factor kappa B-alpha, COX 2, and that long term use is better with pills as they provide
ReplyDeletecontinual pituirary gland increases. Foods such as oatmeal, vegetables and grains.
It will not only help you build an amazing
body but also boost your physical endurance; HGH Advanced can help boost your libido.
my web page ... HGH decreases
http://androidroadies.blogspot.in/
ReplyDeleteI am really thankful to the owner of this web page who has shared
ReplyDeletethis fantastic paragraph at here.
Also visit my web blog :: battlefield 3 update
You can certainly see your enthusiasm within the work you write.
ReplyDeleteThe sector hopes for more passionate writers such as you who are
not afraid to mention how they believe. At all times go after your
heart.
Visit my homepage; summer internship
Valuable information. Lucky me I discovered your web site unintentionally, and I am surprised why this twist of fate did not happened in advance!
ReplyDeleteI bookmarked it.
my web site senior citizens travel insurance
This is a great place to start looking for a ring because you will have questions and
ReplyDeletea jewelry store may have more answers than a department store.
The silver-lipped variety produces equally wonderful pearls that are available in white
to silver and frequently have ros. The young people today are ultra-bright but also very materialistic and just for small joys they're willing to pay cash.
Also visit my web site - promise ring love quotes
Dirt underneath the fingernails gets to the pimple to infect it
ReplyDeletefurther. During your day especially on hot days, make sure to moisturize your skin
layer. This is specially true since you are trying to do away with the
background and provides your model inside most
flattering light possible. Although it is best to have regular bowel motions the natural way.
Feel free to surf to my homepage; Acne won't go away
A promise ring is a kind of commitment to
ReplyDeleteyour partner. Having personal contacts with the jeweler is extremely
important in case you need to resize or modify the ring.
Selecting from birthstone, diamond, gemstone, type of ring, engraving, or
symbolism in the ring or ring setting can produce a ring to impress even the most discriminating taste
for jewelry.
Here is my blog :: webpage []
I know too late but i guess ur answer here;
DeleteGo > AnimationView.java class:
and edit this:
mMovie.draw(canvas, getWidth() - 200, getHeight()-200);
getWidth() - 200 and getHeight()-200 values.
I hope it works for u.
Tungsten rings can be worn as a wedding band, couple rings, promise
ReplyDeletering or fashion ring. Apart from precious metal,
you'll be able to also select platinum which is often a tiny lighter around the weight facet. I know it may seem as if I'm contradicting the advice
I have already given you, but hear me out.
Visit my weblog - promise rings $300
Some people report slight feelings of tingling, itching,
ReplyDeleteor burning whenever they apply baking soda with their face, but also for
most, it isn't really enough to cause discomfort. If homemade mask doesn't
help you, try to increase the risk for other one. This increases oxygen
on the skin, that might help prevent zits. This will
demand acute attention when consuming foods over time.
Have a look at my blog - Acne Makeup
This site was... how do I say it? Relevant!! Finally I have found something that helped
ReplyDeleteme. Thanks a lot!
Also visit my web blog bodybuilding diets for men
Wow, amazing weblog layout! How lengthy have you been blogging for?
ReplyDeleteyou make blogging glance easy. The overall look of your web site is fantastic, as smartly as
the content!
My page - homepage ()
Hey! This post couldn't be written any better! Reading this post reminds me of my previous room mate! He always kept chatting about this. I will forward this page to him. Pretty sure he will have a good read. Thank you for sharing!
ReplyDeleteFeel free to visit my weblog; easy ways to lose weight
This is one of the best example...
ReplyDeleteThank you so much...
thank u
Deletei need that image in the full bakground how ???
ReplyDeleteadf.ly is not responding. so I cannot download your source code.
ReplyDeleteHey TY so Much., But how to stop this animation.? And what about keeping the image full screen.? Can you help.? Thanx for this only perfect tutorial available on net for GIF Animation.
ReplyDeleteThis comment has been removed by the author.
ReplyDeletehow to change the position of the gif? -.-
ReplyDeleteThank You!~
hi
ReplyDeletegreat job
but actually how can i properly use it in a whatever activity?
i put the gif in AnimationView, i changed the package with the name of my app
then i'd like to view the gif in an activity
i put on the xml the the 2 line you described
but should i put something else?
thanks
thanks man, its working fine...
ReplyDeletei use the code to build application for this website. FanPhobia Celebrities Database
When I import it to eclipse I can' t run because a "!" shows up, and it says there is an error but I can't find it.
ReplyDeleteIf u want to size set the size of the GIF equal with your screen put this
ReplyDeletecanvas.scale((float)this.getWidth() / (float)mMovie.width(),(float)this.getHeight() / (float)mMovie.height());
Put it before mMovie.draw(canvas,0,0);
download source code is not working
ReplyDeletekindly correct it
Excellent Job man....Thanks alot.....Can you please just tell me how to resize my animation and put at bottom of page.....
ReplyDelete