How to stop android from redrawing the entire screen whenever something changes?

I have an application that allows users to create complex screen layouts from a set of predefined controls. These controls then interact with each other to create the ultimate functionality. The problem that I see is that no matter what I do, it seems that any redrawing caused by a change in one control forces the whole screen to redraw (as can be seen from the inclusion of "Show screen changes"). Since I have many custom controls without a lot of XML behind them, this redrawing can be quite slow.

For example, one control may be a calculator that is built from several linear layouts. Another could be a dynamically created assembly of a grid of commands from linear layouts. Then, each of them is added to the parent relative layout when the screen loads. Pressing a key on the calculator causes the command grid to redraw, although nothing has changed in any of its representations.

I tried turning on hardware acceleration and changing all types of view layers to LAYER_TYPE_HARDWARE without any luck.

How can I make sure that only a specific section of the screen is redrawn? At the moment, I do not make any calls for canceling myself, but I have my own versions of buttons, layouts and other components of the user interface, so if I need to go to this control level, at least there is already a structure for this.

+5
source share
1 answer

it looks something like this: Moving the Android View and preventing onDraw from being called again, however, if you just want to draw a section, try calling invalidate(rect)where rect is Rectwhere you define the area to be redrawn except for that afaik that you can't.

0
source

All Articles