こんにちは、のようなアニメーションを作成しようとしていますが、これは100%ではありません。これは、いくつかの静的なアクティビティで発生します。Androidアニメーションのヘルプ
しかし、私はどこにもいません。ドキュメントには例がなく、APIの例は受け入れられないだけです。そのようなアニメーションを作るのはとても難しいことではありません。
私のコードを貼り付けています。私を助けてください。
クラスファイル
import android.app.Activity;
import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RelativeLayout;
public class AnimationTest extends Activity {
AnimationDrawable animation;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button btnStart = (Button) findViewById(R.id.btnStart);
final ImageView imgView = (ImageView) findViewById(R.id.img);
btnStart.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startAnimation();
}
});
imgView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
}
});
}
class Starter implements Runnable {
public void run() {
animation.start();
}
}
private void startAnimation() {
animation = new AnimationDrawable();
animation.addFrame(getResources().getDrawable(R.drawable.one), 100);
animation.addFrame(getResources().getDrawable(R.drawable.two), 100);
animation.addFrame(getResources().getDrawable(R.drawable.three), 100);
animation.addFrame(getResources().getDrawable(R.drawable.four), 100);
animation.addFrame(getResources().getDrawable(R.drawable.five), 100);
animation.addFrame(getResources().getDrawable(R.drawable.six), 100);
animation.addFrame(getResources().getDrawable(R.drawable.seven), 100);
animation.addFrame(getResources().getDrawable(R.drawable.eight), 100);
animation.setOneShot(false);
ImageView imageView = (ImageView) findViewById(R.id.img);
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(80, 90);
params.alignWithParent = true;
params.addRule(RelativeLayout.CENTER_IN_PARENT);
imageView.setLayoutParams(params);
imageView.setImageDrawable(animation);
imageView.post(new Starter());
}
}
XMLファイル
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" android:text="Frame by Frame Animation Example"
android:gravity="center" />
<RelativeLayout android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_gravity="center_horizontal">
<ImageView android:id="@+id/img" android:layout_width="80px"
android:layout_height="90px" android:layout_centerInParent="true" />
<Button android:id="@+id/btnStart" android:text="Start Animation"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentRight="true" />
</RelativeLayout>
</LinearLayout>
画像、することができますいくつかの他の画像の過去すぎ 124
EDIT 私は STEP1を達成したい:魚が左サイドから setp2来る:魚は右側から来て
STEP3:心が表示され、両方の魚 STEP4の中心部に大きな成長します:その後、小さな心は離れて飛ぶと
どのようにアニメーション化しますか?そして、あなたはそれぞれの心が別々に動くようにしたいですか?または、イメージ全体に何かをさせたいのですか? – FoamyGuy
私が欲しいものを編集させてください –