shripal
shripal

Reputation: 1222

how can we use animation one image after another image?

how can we use animation if i want one image after another image i had some code but it is not working

Context mContext;
 protected void onCreate(Bundle savedInstanceState) {
     super.onCreate(savedInstanceState);
     setContentView(R.layout.animationdemo);
     Resources res = mContext.getResources();
     TransitionDrawable transition = (TransitionDrawable) res.getDrawable(R.drawable.transitiondrawable);
     ImageView image = (ImageView) findViewById(R.id.imgView);
     image.setImageDrawable(transition);
     transition.startTransition(1000);
 }

and made one xml file transitiondrawable.xml file into drawable folder

<transition xmlns:android="http://schemas.android.com/apk/res/android">
  <item android:drawable="@drawable/endoscope_"/>
  <item android:drawable="@drawable/endoscope_2"/>
</transition>

and one layout file animationdemo.xml

<?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"
    android:layout_gravity="center">


<ImageView
 android:id="@+id/imgView"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content">
 </ImageView>
</LinearLayout>

please give me idea where i m wrong

Upvotes: 0

Views: 3428

Answers (2)

FoamyGuy
FoamyGuy

Reputation: 46856

You could also use a relative layout instead of linear. Then stack two ImageViews on top of each other. And use a fade out animation on the top one. This will give the effect of one image fading into another

Upvotes: 1

pedr0
pedr0

Reputation: 3011

You have to use an frame-by-frame animation, see this:

http://www.twintechs.com/blog/?p=35

Upvotes: 0

Related Questions