将图像视图从一个点移动到另一个
moving Image View from point to another
我想在单击特定按钮时将图像视图从一个点移动到另一个点。
这是我的代码:
int e = 0 ;
Button d = (Button)findViewById(R.id.button1);
d.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
TranslateAnimation move = new TranslateAnimation(e, e + 1, e, e + 1);
move.setDuration(1000);
move.setFillAfter(true);
image.startAnimation(move);
}
});
但是当我点击按钮时没有任何反应!
我如何让它发挥作用?
您的动画可能有效,但它只会将视图移动一个像素,这不是很明显。尝试更改翻译动画的值。
我想在单击特定按钮时将图像视图从一个点移动到另一个点。
这是我的代码:
int e = 0 ;
Button d = (Button)findViewById(R.id.button1);
d.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
TranslateAnimation move = new TranslateAnimation(e, e + 1, e, e + 1);
move.setDuration(1000);
move.setFillAfter(true);
image.startAnimation(move);
}
});
但是当我点击按钮时没有任何反应! 我如何让它发挥作用?
您的动画可能有效,但它只会将视图移动一个像素,这不是很明显。尝试更改翻译动画的值。