动态加组件,居中,padding margin, radiogroup 要重新remove 再加一下 LinearLayout.LayoutParams params= new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.MATCH_PARENT, 1); params.setMargins(10,10,10,10); for(int i=0;i t
LinearLayout.LayoutParams params= new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.MATCH_PARENT, 1); params.setMargins(10,10,10,10); for(int i=0;i< time.data.length;i++){ AdPriceEntity.Price temp=time.data[i]; RadioButton rb=(RadioButton)inflater.inflate(R.layout.comp_rb,null); rb.setText(temp.detail_time+"\n"+temp.detail_price); rb.setId(Integer.valueOf(i+5000)); rb.setTag(R.id.tag_a,temp.detail_time); rb.setTag(R.id.tag_b,temp.detail_price); rb.setPadding(5,5,5,5); if(i<3){ llPrice1.addView(rb,params); }else{ llPrice2.addView(rb,params); } } mrgMoney.removeAllViews(); mrgMoney.addView(llPrice1); mrgMoney.addView(llPrice2);