2016-11-14 9 views
0

シェイプを作成した後、アニメーションを設定する方法がわかりません。私が作成する円は画面の中央にあり、右マージンに移動する必要があります。誰かがそれをアニメートする方法を説明することはできますか?アンドロイド - シェイプのアニメーション

@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_main);  
    Bitmap bg = Bitmap.createBitmap(480, 800, Bitmap.Config.ARGB_8888); 
    Canvas canvas = new Canvas (bg); 
    paint.setAntiAlias(true); 
    canvas.drawCircle(canvas.getWidth()/2, (float) (canvas.getHeight()/1.8), 13, paint); 

答えて

0

単純なアニメーションを行うには、アニメーション要件のあるxmlを作成します。必要なオブジェクトにOnViewCreated()メソッドのアニメーションを適用します。ここ

チェックビューアニメーション:https://developer.android.com/guide/topics/graphics/view-animation.html

例:あなたはnfcTerminalオブジェクトをアニメーション化したい場合は、単に翻訳し、アルファプロパティを持つnfc_terminal_bounce.xmlを作成します。

サンプルコード:

nfcTerminal.startAnimation(AnimationUtils.loadAnimation(のgetContext()、R.anim.nfc_terminal_bounce))。

+0

そして、どのように私の 'キャンバスサークル'をxmlファイルに入れるのですか? –

関連する問題