TranlateAnimation applied to an ImageView leaves trail

All your problems with Audio, Video and Images.

TranlateAnimation applied to an ImageView leaves trail

Postby Chinaski » Sat Jul 02, 2011 1:50 pm

Hi everybody, I've been recently struggling with the TranslateAnimation framework provided by the Android UI library.

I have designed a RelativeLayout which has a GridView taking up the 80% of the screen more or less and an ImageView at the bottom of the screen. The latter it's supposed to be moving around the botttom of the screen constantly, with random directions.

Here's the layout:

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3.    android:layout_width="fill_parent"
  4.    android:layout_height="fill_parent"
  5.    android:background="@drawable/background_img">
  6.  
  7.     <ImageView
  8.        android:id="@+id/bottom_fish"
  9.        android:layout_alignParentBottom="true"
  10.        android:adjustViewBounds="true"
  11.        android:cropToPadding="true"
  12.        android:scaleType="centerInside"
  13.        android:layout_width="wrap_content"
  14.        android:layout_height="wrap_content"
  15.        android:layout_marginBottom="40dp"
  16.        android:layout_alignParentLeft="true"
  17.        android:layout_weight="0"
  18.        android:src="@drawable/little_fish_right"
  19.    ></ImageView>
  20.  
  21.     <GridView
  22.        android:id="@+id/gridview"
  23.        android:layout_width="fill_parent"
  24.        android:layout_height="wrap_content"
  25.        android:layout_alignParentTop="true"
  26.        android:layout_above="@id/mouin_bottom"
  27.        android:columnWidth="90dp"
  28.        android:numColumns="4"
  29.        android:verticalSpacing="10dp"
  30.        android:horizontalSpacing="10dp"
  31.        android:stretchMode="columnWidth"
  32.        android:gravity="center"
  33.    />
  34.  
  35. </RelativeLayout>
  36.  
Parsed in 0.004 seconds, using GeSHi 1.0.8.4


And here's the TranslateAnimation:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. TranslateAnimation slide = new TranslateAnimation(x0, newX, y0, newY);
  2. slide.setFillAfter(true);
  3. slide.setInterpolator(new LinearInterpolator());
  4. slide.setDuration(duration);  
  5. slide.setAnimationListener(animationListener);
  6. iv.startAnimation(slide);
  7.  
  8. x0 += newX;
  9. y0 += newY;
  10.  
Parsed in 0.030 seconds, using GeSHi 1.0.8.4


The AnimationListener assigned to the animation just calls this method on the onAnimationEnd function.

The matter is that when the image is moving from right to left it eventlually leaves bitmap traces on the screen, being removed after a while.

Any idea where the problem could be placed?

Thank you.
Chinaski
Freshman
Freshman
 
Posts: 2
Joined: Sat Jul 02, 2011 11:36 am

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: No registered users and 12 guests