onSizeChanged多次调用,什么时候画?

时间:2016-01-11 20:53:03

标签: android android-custom-view

我在onMeasure方法中绘制自定义视图的内容。但我意识到这种方法被多次调用。绘制我的视图的正确方法是什么?我依赖于视图尺寸。

01-11 21:44:32.696 28039-28039/ D/TilesView: onMeasure(MeasureSpec: EXACTLY 704, MeasureSpec: EXACTLY 1070)
01-11 21:44:32.696 28039-28039/ D/TilesView: onMeasure(MeasureSpec: EXACTLY 704, MeasureSpec: EXACTLY 1070)
01-11 21:44:32.700 28039-28039/ D/TilesView: onSizeChanged(704, 1070, 0, 0)
01-11 21:44:32.801 28039-28039/ D/TilesView: draw 82 ms
01-11 21:44:32.930 28039-28039/ D/TilesView: onDraw()
01-11 21:44:33.100 28039-28039/ D/TilesView: onMeasure(MeasureSpec: EXACTLY 704, MeasureSpec: EXACTLY 958)
01-11 21:44:33.100 28039-28039/ D/TilesView: onMeasure(MeasureSpec: EXACTLY 704, MeasureSpec: EXACTLY 958)
01-11 21:44:33.101 28039-28039/ D/TilesView: onSizeChanged(704, 958, 1070, 704)
01-11 21:44:33.118 28039-28039/ D/TilesView: draw 9 ms
01-11 21:44:33.124 28039-28039/ D/TilesView: onDraw()

1 个答案:

答案 0 :(得分:0)

所有显示活动都应该在onDraw()方法中完成。