android - Display 3 buttons in a row IN a scroll view -
at moment have list of buttons showing in scrollview
buttons on left hand side , go down in 1 column.
i these buttons shown in columns of 3, 3 buttons in 1 row when add row dynamically
here current code have display these buttons
// find scrollview scrollview scrollview = (scrollview) findviewbyid(r.id.scrollview); // create linearlayout element linearlayout linearlayout = new linearlayout(this); linearlayout.setorientation(linearlayout.vertical); // add buttons (int = 0; < 3; i++) { linearlayout.setlayoutparams(new viewgroup.layoutparams(viewgroup.layoutparams.wrap_content, viewgroup.layoutparams.wrap_content)); (int j = 0; j < 20; j++) { button button = new button(this); button.settext("some text"); linearlayout.addview(button); } } // add linearlayout element scrollview scrollview.addview(linearlayout); }
i tried setting layout parameters buttons didn't change anything
any ideas?
thanks
try logic
// find scrollview scrollview scrollview = (scrollview)findviewbyid(r.id.scrollview); // create linearlayout element linearlayout linearlayout = new linearlayout(this); linearlayout.setorientation(linearlayout.vertical); linearlayout.setlayoutparams(new viewgroup.layoutparams(viewgroup.layoutparams.wrap_content, viewgroup.layoutparams.wrap_content)); // add buttons (int = 0; < 20; i++) { linearlayout linearlayoutchild = new linearlayout(this); linearlayoutchild.setorientation(linearlayout.horizontal); linearlayoutchild.setlayoutparams(new viewgroup.layoutparams(viewgroup.layoutparams.wrap_content, viewgroup.layoutparams.wrap_content)); (int j = 0; j < 3; j++) { button button = new button(this); button.settext("some text"); linearlayoutchild.addview(button); } linearlayout.addview(linearlayoutchild); } // add linearlayout element scrollview scrollview.addview(linearlayout);
Comments
Post a Comment