i have created row of buttons dynamically 1 of buttons has little more text. buttons in row having same size button containing more text these row of buttons larger other buttons in other rows. following code:
linearlayout dynamicview = (linearlayout)findviewbyid(r.id.buttons); (int = 0; < 3; i++) { linearlayout row = new linearlayout(this); row.setlayoutparams(new layoutparams(layoutparams.match_parent, layoutparams.match_parent)); (int j = 0; j < 5; j++) { button btntag = new button(this); linearlayout.layoutparams param = new linearlayout.layoutparams( layoutparams.match_parent, layoutparams.match_parent,1.0f); btntag.setlayoutparams(param); display display=getwindowmanager().getdefaultdisplay(); int width=display.getwidth(); btntag.settext("" + (j + 1 + (i * 5))); btntag.setid(j + 1 + (i * 5)); btntag.setwidth(width/5); if(btntag.getid() == 13) { btntag.settext("has more txt"); } if(btntag.getid() == 14) { btntag.setvisibility(view.invisible); } if(btntag.getid() == 15) { btntag.settext("c"); } row.addview(btntag); } dynamicview.addview(row); }
where r.id.buttons in xml is:
<linearlayout android:id="@+id/buttons" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" android:layout_alignparentbottom="true"> </linearlayout>
could please let me know if there way in can make 3 rows of buttons have same width , height?
thank you.
setgravity(..) 'center' should work. can try column stretch mode. code little confusing because looks doing more should.
i wait answer before simulating in machine , post code
Comments
Post a Comment