Android: FrameLayout not respecting draw order -


i have framelayout 4 surfaceviews arranged in 2x2 grid. user can resize each of views.

i'd views drawn in order of area, largest view drawn first , on. each time view resized, order views area, , update framelayout:

public void reorderviews() {         plotview child1;         plotview child2;         boolean swap = false;          for(int = 0; < layout.getchildcount(); i++) {             child1 = (plotview) layout.getchildat(i);             for(int j = + 1; j < layout.getchildcount(); j++) {                 child2 = (plotview) layout.getchildat(j);                 if(child1.area < child2.area) {                     layout.removeviewat(j);                     layout.addview(child2, i);                 }             }         }      } 

this works, in sense framelayout's children array holds views in correct order. after re-ordering, views continue draw in original order (i.e. order in added).

i've tried requesting layout on framelayout, on individual child views, on framelayout's parent view. i've tried invalidating everything. i've overridden framelayout's ondraw hoping force correct draw order. no go.

a few points: i'm using framelayout rather grid because i'd larger views obscure smaller views, instead of having larger view push smaller view aside, behaviour in gridview.

in order position child views properly, adjust margins , set gravity 'top' (it doesn't seem matter value use gravity, long gravity set something, margins work). might gravity issue?

also, i'm sure there's more efficient way reorder views, there's 4 total, works ok.

surfaceview widgets not drawn using normal android layout mechanism. instead, each surfaceview gets own, separate window. suspect windows not being reordered when views reordered. you're trying work other kind of widget.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -