2017-04-12 5 views
-1

私はこのようなオブジェクトをアニメーション化したいと考えています: 私の質問はどうですか?(b)画面から抜けずにオブジェクトをアニメーション化するにはどうしたらいいですか?どうすればオブジェクトをアニメーション表示できますか?

オブジェクトo;
nextX = random.nextInt(b);

ObjectAnimator a1;

A1 = ObjectAnimator.oFFloat(O、 "X"、nextX)

答えて

0

あなたは、画面の高さと幅

public static int getScreenHeight(Context ctx) { 
     DisplayMetrics metrics = ctx.getResources().getDisplayMetrics(); 
     return metrics.heightPixels; 
    } 

    public static int getScreenWidth(Context ctx) { 
     DisplayMetrics metrics = ctx.getResources().getDisplayMetrics(); 
     return metrics.widthPixels; 
    } 

を取得し、この

Random randX = random.nextInt(getScreenWidth(ctx)); 
Random randY = random.nextInt(getScreenheight(ctx)); 

ObjectAnimator moveX = ObjectAnimator.ofFloat(object, "x", randX); 
ObjectAnimator moveY = ObjectAnimator.ofFloat(object, "y", randY); 
のように使用することができます
関連する問題