RelativeLayout.LayoutParams relativeParams =
new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
relativeParams.addRule(RelativeLayout.CENTER_HORIZONTAL)
LinearLayout.LayoutParams lineParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
LinearLayout line = new LinearLayout(this);
LinearLayout line1 = new LinearLayout(this);
line.addView(myTt0, lineParams);
line.addView(myTx0, lineParams);
line.addView(myTx1, lineParams);
line1.addView(myTx, lineParams);
relativeLayout.addView(line,
relativeParams); //
Attention:if the two params are same, the larger layout will be cliped.
relativeLayout1.addView(line1,
relativeParams);
////////////////////////////////////////////////////////////
So the relativeParams should use different ones attach to more than one layouts as below:
relativeLayout.addView(line, relativeParams);
relativeLayout1.addView(line1, relativeParams_c);