I'd like to translate an image from left to right on emulator using android animation. I'm new to android animation. How could I do that?
Thanks.
解决方案ll = new LinearLayout(this);
ll.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
ll.setOrientation(LinearLayout.VERTICAL);
tv = new TextView(this);
tv.setText("Animation");
moveLefttoRight = new TranslateAnimation(0, 200, 0, 0);
moveLefttoRight.setDuration(1000);
moveLefttoRight.setFillAfter(true);
button = new Button(this);
button.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
button.setText("PressMe");
button.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
tv.startAnimation(moveLefttoRight);
}
});
ll.addView(tv);
ll.addView(button);
setContentView(ll);
is one way of doing it.