private void addWeightElement() { // currentItemsCnt++; WeightItem item = new WeightItem(); item.position = helper.itemsList.size(); item.weight = 100 / currentItemsCnt; helper.itemsList.add(item); TextView text = new TextView(this); text.setText("pos" + item.position); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); params.weight = item.weight; text.setLayoutParams(params); text.setId(0x00001000 + item.position); text.setBackgroundColor( Color.rgb( 0xFF / (item.position + 1), 0x7F / (item.position + 1), 0xFF / (item.position + 1))); weightView.addView(text); // Liean container TextView seekText = new TextView(this); seekText.setText("pos " + item.position); seekText.setPadding(0, 0, 10, 0); SeekBar seekBar = new SeekBar(this); seekBar.setId(0x00001000 + item.position + 30); seekBar.setMax(100 / currentItemsCnt); seekBar.setOnSeekBarChangeListener(new SeekListener(item)); seekBar.setPadding(0, 5, 0, 5); seekBar.setProgress(seekBar.getMax()); LinearLayout linearLayout = new LinearLayout(this); // LinearLayout.LayoutParams params = new // LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, // ViewGroup.LayoutParams.WRAP_CONTENT); seekBar.setLayoutParams(params); linearLayout.addView(seekText); linearLayout.addView(seekBar); seekView.addView(linearLayout); TextView ttt = new TextView(this); ttt.setId(0x00002000 + item.position); ttt.setText("weight of item " + item.position + " w = " + item.weight); changeView.addView(ttt); }