Android weightsum not working as expected -


i have 1 horizontal linear layout width = match_parent , weightsum=5. if insert 5 vertical linear layouts each width=0 , weight=1 looks expected, layouts each same width. if add 2 vertical each width=0 , weight=1 take more space should. expected them take 1/5 of space.

maybe correct behaviour take more space , understood concept of weight/weightsum wrong.

thanks help!

edit: try add code

linearlayout linear=null;              linearlayout.layoutparams layoutparams= new               		linearlayout.layoutparams(linearlayout.layoutparams.match_parent,               		linearlayout.layoutparams.wrap_content);    linear=new linearlayout(getapplicationcontext());              		linear.setorientation(linearlayout.horizontal);              		linear.setlayoutparams(layoutparams);              		linear.setpadding(15, 0, 15, 10);              		linear.setweightsum(float.valueof(modulo));  //modulo 5 in example      linearlayout linear2=new linearlayout(getapplicationcontext());  linearlayout.layoutparams lp1 = new linearlayout.layoutparams(0,                   		linearlayout.layoutparams.wrap_content, 1f);  if(count%modulo!=modulo-1){          lp1.setmargins(0, 0, 15, 0);  } else {          lp1.setmargins(0, 0, 0, 0);         }  linear2.setlayoutparams(lp1);  linear2.setorientation(linearlayout.vertical);

i add layout linear 2 linear in loop why can click run code :d

if logical solution not work fill rest with

<view     android:layout_width="0dp"     android:layout_height="0dp"     android:layout_weight="3"/> <!-- or whatever rest --> 

or

view space = new view(this); // never create views app context! linearlayout.layoutparams spaceparams = new linearlayout.layoutparams(0, 0, 3f); linear.addview(space, spaceparams); 

note: space widget didn't work in case.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -