android - Stretch layout to screen -


i have following layout. i'm using layout_weight="1", stretch fit screen uniformly. user has option delete images, setting visibility="gone".

let's user deletes both images in middle linearlayout, want layout disappear. currently, if delete both images empty layout stays there leaving gap. how might work other layouts fill in empty space?

<linearlayout android:orientation="vertical" android:width="fill_parent" android:height="fill_parent">    <linearlayout android:orientation="horizontal" android:layout_weight="1">       <image></image>       <image></image>    </linearlayout>    <linearlayout android:orientation="horizontal" android:layout_weight="1">       <image></image>       <image></image>    </linearlayout>    <linearlayout android:orientation="horizontal" android:layout_weight="1">       <image></image>       <image></image>    </linearlayout> </linearlayout> 

you'll want in java code. in code set linearlayout (which subclass of view) invisible.

linearlayout layout1 = this.findviewbyid(r.id.linearlayout1); //some logic here determine if images in layout have been removed or not //if gone then.. layout1.setvisibility(view.invisible); 

something that. you'll want see if expands existing layouts take void left. haven't tested i'm guessing may solve solution? :-)


Comments