8

私は最近、Android UI ライブラリによって提供される TranslateAnimation フレームワークに苦労しています。

画面の 80% を多かれ少なかれ占める GridView と、画面の下部にある 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 関数でこのメソッドを呼び出すだけです。

問題は、画像が右から左に移動すると、最終的に画面にビットマップの痕跡が残り、しばらくすると削除されることです。

問題をどこに置くことができるか考えていますか?

ありがとうございました。

4

2 に答える 2

1

After you call iv.startAnimation(slide), you may need to call invalidate() on the view's parent. I've had that problem before. I'm assuming you've solved the issue before, but hopefully this will be helpful for others.

于 2013-07-16T19:18:54.130 に答える
0

レイアウト設計の問題だと思います。あげてみて

android:layout_width="fill_parent" 

それ以外の

android:layout_width="wrap_content"
于 2013-06-25T18:51:04.607 に答える