Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6228735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:26:25+00:00 2026-05-24T09:26:25+00:00

i have develop one application in which i want to play gif animation. for

  • 0

i have develop one application in which i want to play gif animation.
for that i have refer this

CODE

public class GIFDemo extends GraphicsActivity {
ImageView imageView1;
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.main);
    imageView1  = (ImageView) findViewById(R.id.imageView1);



}
private static class GIFView extends View{

    Movie movie,movie1;
    InputStream is=null,is1=null;
    long moviestart;
    long moviestart1;
    public GIFView(Context context) {
        super(context);
        is=context.getResources().openRawResource(R.drawable.border_gif);

        movie=Movie.decodeStream(is);

    }

    @Override
    protected void onDraw(Canvas canvas) {
        canvas.drawColor(0xFFCCCCCC);
        super.onDraw(canvas);
        long now=android.os.SystemClock.uptimeMillis();

         if (moviestart == 0) {   // first time
             moviestart = now;

         }
         if(moviestart1==0)
         {
             moviestart1=now;
         }

         int relTime = (int)((now - moviestart) % movie.duration()) ;
        // int relTime1=(int)((now - moviestart1)% movie1.duration());

         movie.setTime(relTime);
        // movie1.setTime(relTime1);
         movie.draw(canvas,10,10);
         //movie1.draw(canvas,10,100);
         this.invalidate();
    }
}
}

Main :

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<TextView  
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/hello"
    />
<ImageView android:layout_height="wrap_content"
    android:layout_width="wrap_content" 
    android:id="@+id/imageView1"
    android:src="@drawable/icon"></ImageView>
</LinearLayout>

so problem is i want to set class GIFView in Imageview so i have refer post like this
but not get proper example. so can you give me proper example and explanation that how can i set view in ImageView

Thanks
nik

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T09:26:26+00:00Added an answer on May 24, 2026 at 9:26 am

    I don’t think it is meaningful to ‘set the view’ of an ImageView (in the way you are suggesting), and I don’t think you even need an ImageView in this case. You have implemented a custom View that is able to draw a GIF without any dependency on the ImageView class – you just have to use it!

    With minimal changes, assuming the GIFView works, you can just instantiate a GIFView and then add it to the main layout. Let your onCreate be as follows:

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    
        setContentView(R.layout.main);
    
        // let your LinearLayout have an id of 'container'
        LinearLayout container = (LinearLayout) findViewById(R.id.container);
        GIFView gifView = new GifView(this);
        container.addView(gifView);
    
    }
    

    You can get rid of the ImageView from the layout entirely and just use your GIFView that was instantiated in code. Alternatively, you can make your GIFView a standalone (non-inner) class and add it to your XML layout by specifying the full package name, e.g.

    <com.nik.view.GIFView
      id="@+id/gifview"
      ... />
    

    You would also need to write the view constructor GIFView(Context context, AttributeSet attrs) because that is the one that is expected when using XML.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have to develop an application which parses a log file and sends specific
I have to develop an application using C#.net that has to be run once
There is one software application in which foxpro is used as back-end. Now this
I want to develop an application in which user input an image (of a
I want to develop a mobile application which can work in GPS/GPRS based phones.
I have to develop software for a USB scale that, when you press a
I have to develop a tool in C# that retrieves some data from an
This is my first time with Web services. I have to develop web services
I have been asked to develop some usercontrols in ASP.NET that will at a
I develop a variety of applications and have 3-4 miscellaneous libraries that I reuse

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.