开发者

Android : TextView onDraw() only once?

I'm creating a custom TextView by using T开发者_开发知识库extPaint in the onDraw() method. however this is causing severe problems for my app. performance wise I mean.

The onDraw() method gets called over and over again . but i just want it to draw once :(

i tried using setDrawingCacheEnabled(true); but no effect there.

There is also a viewflipper with textviews in the main layout rotating automaticly, could this be causing everything to redraw ?

can anyone give me some pointers here ?


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?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜