一个动画器,它可以使剪切圆产生动画效果。

构造方法

ViewAnimationUtils.createCircularReveal( view, centerX, centerY, startRadius, endRadius)

Parameters
view 控件视图,一般传ID即可
centerX 动画圆心的x坐标
centerY 动画圆心的y坐标
startRadius 动画圆的起始半径。
endRadius 动画圆的结束半径。

示例:

  1. require "import"
  2. import "android.os.*"
  3. import "android.app.*"
  4. import "android.view.*"
  5. import "android.widget.*"
  6. local layout = loadlayout({
  7. LinearLayout,
  8. layout_width = "fill",
  9. layout_height = "fill",
  10. gravity = "center",
  11. {
  12. Button,
  13. layout_width = "100dp",
  14. layout_height = "50dp",
  15. text = "开始动画",
  16. id = "button",
  17. },
  18. })
  19. activity.setContentView(layout)
  20. function initAnimate()
  21. -- 定义揭露动画
  22. local animate = ViewAnimationUtils.createCircularReveal(button,0,0,500,0)
  23. -- 设置动画时间
  24. animate.setDuration(3000)
  25. -- 点击开始动画
  26. button.onClick = function()
  27. animate.start()
  28. end
  29. end
  30. function main()
  31. -- 延时300毫秒再加载动画,否则挂载不上
  32. task(300,function()
  33. initAnimate()
  34. end)
  35. end

效果:

揭露动画 - 图1