android - Jerky scrolling when adding/removing views to ScrollView's child -


i hope can give idea on how improve performance of scrolling on app.

basically have tiles/images being generated in secondary thread, , once ready add them relativelayout on specific position layoutparams. i'm setting size of relativelayout fixed avoid complexities. relativelayout 1 add scrollview.

i listen scroll change event of scrollview, able request new tiles when scroll new position. when happens, new tiles generated on secondary thread, , @ same time information remove old tiles not necessary anymore (this helps keep quantity of tiles not blow out memory).

but, main problem here while scrolling , adding/removing tiles (using addview() , removeview()) scrolling jerky. have same app in ios, using same approach , scrolling perfect.

here's have:

// main activity relativelayout tilecanvas = new relativelayout(this); tilecanvas.setlayoutparams(new layoutparams(800, 10000)); scrollview scroll = new scrollview(this). scroll.addview(tilecanvas); setcontentview(scroll);  ...  private void addtile(tileinfo tileinfo) {     imageview image = new imageview(this.getcontext());     image.setimagebitmap(tileinfo.mbitmap);     relativelayout.layoutparams params = new relativelayout.layoutparams(tileinfo.mwidth, tileinfo.mheight);     params.leftmargin = tileinfo.mleft;     params.topmargin = tileinfo.mtop;     tilecanvas.addview(image, params);  } 

i checked if stop calling addtile() after sometime, scroll works tiles added in tilecanvas.

i faced same issues in project. why using own filing mechanism gesturedetector? scrollview handles of that. solution found, 1.try reduce if() conditions , unwanted nesting if() condition in code. 2.please write optimistic code structure way increase scrollview speed without jerk. hesitate above step,scrollview affected. thank you.


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -