Android的 - 如何动画画布的一个元素,而不是整个画布或查看? [英] Android - How to animate a single element of Canvas instead of whole canvas or view?
本文介绍了Android的 - 如何动画画布的一个元素,而不是整个画布或查看?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个已被使用的drawLine函数绘制两行自定义视图。我想动画第二行的阿尔法,但每当我试图动画它整个画布动画。我试图找到像什么,但迄今为止并没有得到任何的运气。
I have a custom view with two lines that had been drawn using drawLine function. I want to animate the alpha of second line but whenever i try to animate it whole canvas is animating. I try to find like anything so far but didn't get any luck.
任何帮助将是非常美联社preciated。
Any help would be really appreciated.
感谢。
推荐答案
我会做这样的:
- 在自定义视图实施的onDraw()
- 请不要创建的onDraw()的任何对象
- 提供公共设置,为您的阿尔法场,你在使用的onDraw方法()
- 使用 ObjectAnimator 以动画自定义视图的alpha属性
- Implement onDraw() in your custom View
- Do not create any object in onDraw()
- Provide public set and get methods for your alpha field that you use in onDraw()
- Use ObjectAnimator to animate alpha property of your custom view
大概也<一用href=\"http://developer.android.com/reference/android/view/View.html#invalidate%28int,%20int,%20int,%20int%29\"相对=nofollow>这个而不是调用无效()重绘画布的一部分。
Probably use also this instead calling invalidate() to redraw only part of your canvas.
这篇关于Android的 - 如何动画画布的一个元素,而不是整个画布或查看?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文