android - Optimizing redraws of multiple View objects -


i creating android app dashboard many gauges , indicators on it. have main view added in main activity's oncreate() method. each gauge custom view object added , initialized in main view , drawn in main view's ondraw() method. gauge values updated individual threads launched in main activity's oncreate() method. when thread detects need change gauge value, so, , sends message main view (via message handler) telling particular gauge needs updated (redrawn). using invalidate() in main view's message handler refresh screen. app runs well, wondering if handling display updates efficiently can. question is:

when call invalidate() in main view, assume redrawing gauge views, ones have not changed. if so, more efficient redraw view of gauge has changed? best way that? have tried calling individual view's invalidate() , postinvalidate() methods neither works.

as requested, here current state of ondraw method in main view. there lot more gauges added. bezels static , change if device switches configuration (landscape/portrait). various gauges instantiated gauge class extends view:

@override protected void ondraw(canvas canvas) {      speedobezel.draw(canvas);     tachbezel.draw(canvas);     oilpressbezel.draw(canvas);     oiltempbezel.draw(canvas);      speedogauge.draw(canvas);     tachgauge.draw(canvas);     oilpressgauge.draw(canvas);     oiltempgauge.draw(canvas);  } 

ok, have read many ways animate in android started mix them up. rephrase question:

if developing app many different objects in main view changed @ different intervals, better performance wise to:

  1. add objects main view , use invalidate(rect) in main view update them individually needed, or

  2. add each object layout , use invalidate on each view when require updating.

important note none of objects overlap


Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -