簡體   English   中英

Android中的可點擊對象動畫

[英]Clickable object animation in android

我想將圖像從A點移動到B點,並在移動過程中單擊它。 不僅在開始或結束時,而且在整個過程中。 像一個移動的目標,戳開它。

我見過一些引導人們去使用對象動畫師和查看屬性動畫師的帖子,但是沒有示例,我只是不了解如何從文檔中做到這一點。 有人可以顯示一個簡短的代碼片段來做到這一點嗎? 最好以編程方式不使用XML。 謝謝你的幫助。

編輯:其實我已經設法弄清楚了。 創建圖像(img)后,類似以下內容:

    final ViewPropertyAnimator animator = img.animate();    // The magical View
    animator.scaleX(2);         // Zoom
    animator.scaleY(2);
    animator.setDuration(8000);
    animator.x(300).y(500);

嘗試這個

    ObjectAnimator animator = 
    ObjectAnimator.ofFloat(view, "translationY", view.getTranslationY(), offset).setDuration(300);
    animator.start();

同時,您可以根據需要開始“ translationY”動畫。 在動畫期間,您可以照常單擊視圖。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM