开发者

Animated Gif Image Not Working in Phonegap

'Now I am developing application in Phonegap framework.My question i开发者_如何学编程s animated images are displaying but there is no animation. In browser it is working fine.In emulator only displaying image. How can I fix this issue?


 private static class GIFView extends View{        
            Movie movie;  
            InputStream is=null;  
            long moviestart;  
            public GIFView(Context context) 
            {  
                super(context);  
                is=context.getResources().openRawResource(R.drawable.smile);  
                movie=Movie.decodeStream(is);                 
            }  

            @Override  
            protected void onDraw(Canvas canvas) 
            {  
                super.onDraw(canvas);  

                long now=android.os.SystemClock.uptimeMillis();  

                 if (moviestart == 0) {   // first time  
                     moviestart = now;  
                 }            
                   int relTime = (int)((now - moviestart) % movie.duration()) ;                 
                     movie.setTime(relTime);
                     movie.draw(canvas,100,100); 

                     this.invalidate();  
            }                         
        }    

use this class and add the view to your layout,

 GIFView view=new GIFView(this);

            linear=(LinearLayout)findViewById(R.id.linear);
            linear.addView(view);

it may helps you..

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜