私は最近、Android UIライブラリによって提供されるTranslateAnimationフレームワークに苦しんでいます。ImageViewに適用されたTranslateAnimationはトレイルを残します
私はGridViewが画面の80%を多かれ少なかれ占有し、スクリーンの下部にImageViewを持つRelativeLayoutを設計しました。後者は、画面のボトムの周りを常にランダムな方向に動いているはずです。
ここレイアウトです:
<ImageView
android:id="@+id/bottom_fish"
android:layout_alignParentBottom="true"
android:adjustViewBounds="true"
android:cropToPadding="true"
android:scaleType="centerInside"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="40dp"
android:layout_alignParentLeft="true"
android:layout_weight="0"
android:src="@drawable/little_fish_right"
></ImageView>
<GridView
android:id="@+id/gridview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_above="@id/mouin_bottom"
android:columnWidth="90dp"
android:numColumns="4"
android:verticalSpacing="10dp"
android:horizontalSpacing="10dp"
android:stretchMode="columnWidth"
android:gravity="center"
/>
そして、ここではTranslateAnimationです:
TranslateAnimation slide = new TranslateAnimation(x0, newX, y0, newY);
slide.setFillAfter(true);
slide.setInterpolator(new LinearInterpolator());
slide.setDuration(duration);
slide.setAnimationListener(animationListener);
iv.startAnimation(slide);
x0 += newX;
y0 += newY;
アニメーションに割り当てられたAnimationListenerがちょうどonAnimationEnd関数に、このメソッドを呼び出します。
画像が右から左に移動しているときは、ビットマップのトレースが画面上に残り、しばらくすると削除されます。
問題をどこに置くことができますか?
ありがとうございます。
setFillAfter()メソッドでfalseを指定しようとします。 slide.setFillAfter(false); –