Android: How to get a custom view to redraw partially?

前端 未结 2 788
梦谈多话
梦谈多话 2020-12-02 19:28

I have a custom view that fills my entire screen. (A piano keyboard) When a user touches the key, it causes invalidate() to be called and the whole keyboard get

2条回答
  •  [愿得一人]
    2020-12-02 20:01

    To complement Peterdk's answer, you could save your operations in a Picture instead of a Bitmap.

    • A Bitmap will save all pixels, like he said it could take a lot of memory.
    • A Picture will save the calls, like drawRect, drawLine, etc.

    It depends of what is really heavy in your application : a lot of draw operations, a few draw operations but controlled by heavy calculations, a lot of blank/unused space (prefer Picture) etc...

提交回复
热议问题