android - View with visibility state GONE taking up space on screen -


i experiencing problem views visibility state of gone (undesirably) taking space on screen. problem occurs on api level <= 7 devices, on 8+ devices (after utilized asynctasks populate fields, per show progress bar when activity loading)

a bit of context: created custom view extending linearlayout contains "title" button , (user defined; in cases, it's few textviews, in others it's tablelayouts) "contents". purpose of view toggle view of contents onclick of title button (i don't believe there built-in widget this.. may wrong).

in onlayout() explicitly set visibility state of child views except title gone, first time drawn:

protected void onlayout(boolean changed, int l, int t, int r, int b) {     if(initialdraw) {         setcontentsvisible(false);         initialdraw = false;     }     super.onlayout(changed, l, t, r, b); }  public void setcontentsvisible(boolean visible) {     for(int = 0; < getchildcount(); i++) {         view child = getchildat(i);          if(child != mtitle) {             child.setvisibility(visible ? visible : gone);         }     } } 

moving code onlayout() onmeasure() solves problem.


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -