0

我在 onDraw() 方法中使用 TextPaint 创建了一个自定义 TextView。但是,这给我的应用程序带来了严重的问题。我的意思是表现明智。

onDraw() 方法被一遍又一遍地调用。但我只想让它画一次:(

我尝试使用 setDrawingCacheEnabled(true); 但那里没有效果。

在主布局中还有一个带有 textviews 的 viewflipper 会自动旋转,这会导致所有内容都重绘吗?

任何人都可以在这里给我一些指示吗?

4

1 回答 1

0

As well as enabling the drawing cache, try creating a new bitmap instance in the inDraw and pass that to the Canvas to draw to. In the next call to onDraw, simply draw that bitmap if it is not null. I'm doing this myself and it works a charm to improve performance, though unable to copy the code right now (out using phone).

As for why it is being consistently redrawn, are there any moving overlapping graphics causing it to be invalidated?

于 2011-06-30T08:18:41.280 回答