我创建的自定义进度条与以下内容不同: http://weavora.com/blog/2012/02/23/android-progressbar-with-text/ 或http://colintmiller.com/2010/10/how-to-add-text-over-a-progress-bar-on-android/
我注意到在与canvas相关的操作中,例如在重写onDraw方法中的canvas.drawText(),两个作者都选择以某种方式使视图的状态无效。
一个使用了postInvalidate(),另一个使用了drawableStateChanged()。
没有解释他们的推理。
有人可以说明哪一种是最适合前进的方式吗?
谢谢。
答案 0 :(得分:0)
答案是postInvalidate(),因为drawableStateChanged()根本不起作用,句点(即onDraw永远不会被调用)。