你好家伙我想要在我的对象动画师中得到随机数。 我想获得的随机数为 “TranslationX” `如何获得Android对象动画师的随机数
imagebutton1.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
counter++;
final TextView score = (TextView)findViewById(R.id.textView1);
score.setText("Score:"+counter);
ObjectAnimator anim = ObjectAnimator.ofFloat(imagebutton1, "translationX", 100f, 100f);
anim.setDuration(3600);
anim.start();;
anim.setInterpolator(new AccelerateDecelerateInterpolator());
anim.setRepeatMode(Animation.REVERSE);
anim.setRepeatCount(5);`
我的代码现在采取只X方向的随机数我可以让X和Y在1函数? – Boldbayar
@Boldbayar:翻译视图需要你使用'TranslateAnimation'。请编辑答案 –