2016-11-14 137 views
0

創建形狀後,我不知道如何設置動畫。我創建的圈子位於屏幕的中心,應移至右邊距。有人可以解釋如何製作動畫嗎?android - 動畫形狀

@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與翻譯和alpha屬性。

樣品的編號:

nfcTerminal.startAnimation(AnimationUtils.loadAnimation(的getContext(),R.anim.nfc_terminal_bounce));

+0

我如何將我的'畫布圈'放入xml文件中? –