android - Dynamically added items in LinearLayout margin -
i have code add checkboxes array linearlayout.
linearlayout my_layout = (linearlayout) findviewbyid(r.id.test); (int n = 0; n < listitems.size(); n++) { checkbox cb = new checkbox(getapplicationcontext()); cb.setid(integer.parseint(listitems.get(n).get("cbid"))); cb.settext(listitems.get(n).get("product")); cb.settextcolor(color.black); my_layout.addview(cb); }
how can make sure between each checkbox there margin of 2-3dp? , background of checkboxes has rounded edges?
this xml set boxes in
<linearlayout android:id="@+id/parent" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <linearlayout android:id="@+id/test" android:layout_width="260dp" android:layout_height="wrap_content" android:orientation="vertical" android:paddingleft="10dp" /> <linearlayout android:id="@+id/settings" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" android:background="#13ca8c" /> </linearlayout>
linearlayout my_layout = (linearlayout) findviewbyid(r.id.test); (int n = 0; n < listitems.size(); n++) { checkbox cb = new checkbox(getapplicationcontext()); cb.setid(integer.parseint(listitems.get(n).get("cbid"))); cb.settext(listitems.get(n).get("product")); cb.settextcolor(color.black); linearlayout.layoutparams params = new linearlayout.layoutparams(viewgroup.layoutparams.match_parent, viewgroup.layoutparams.wrap_content); parms.leftmargin = 2; params.rightmargin = 2; params.topmargin = 2; params.bottommargin = 2; my_layout.addview(cb,params); }
and rounded corners use background image
Comments
Post a Comment