问题
I'm experiencing terrible TableLayout performance. I've read some posts here talking about the same ...
Android dynamically created table - bad performance
I use a tablelayout inside an already complex layout. I'm already using many views and of course the more views I use, the less the performance, this is obvious, but I wonder how is it possible that the performance is so bad compared to the rest of widgets.
In my case, a tablelayout with let's say 5*5 textviews (only plain textviews in the rows) causes the system to freeze for even more than 1.5 seconds sometimes just by updating a TextView . I am not talking about rendering the whole table, but just updating one textview inside the tablelayout.
I suspected of setColumnsStretchable(), but even setting it to never stretch, the performance is the same.
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
final TextView target=(TextView)seekBar.getTag();
target.setText(""+progress);
}
This is the code I use to update a cell. As you see, it's part of a SeekBar listener. I don't even have to findView() or anything, as I store the target textview as the seekbar's tag.
So, moving the seekbar causes jumps: It takes more than one second!! to do the setText() alone. If I update any other textview which is not inside the table, the update is immediate, as expected.
If my table is 10*10, well, it takes like 3 seconds!
Is in your experience TableLayout a no-no or I might be doing something wrong? Maybe some magic values for the rows or cells layoutparams?
Thanks in advance.
来源:https://stackoverflow.com/questions/16826983/ultra-slow-tablelayout-performance