Hey I will shortly describe what I do in the code below: I create an ViewStub (Vs) and add it to the RelativeLayout (Rl). Then I want to add a new Vs to the same RL, so I create the stub2 and add it to rl. Then I reference to the Rl (which is inflatet) of the first and of the second Vs (rlInf1 ,rlInf2) And then I set the Rl.Layoutparams so that the rlInf2 should be below the rlInf1 but they are overlapping. How can I set the LayoutParams so that the new ViewStub is below the old one? Any Ideas?
(I did not add the ViewStub in XML, but in Java-Code)
//Löschen des Standard-Tv
TextView tv = (TextView) findViewById(R.id.tvNoContentInfo);
RelativeLayout rl = (RelativeLayout) findViewById(R.id.Layout_ContentInfo);
rl.removeView(tv);
//Erstellen eines ViewStubs
ViewStub stub1 = new ViewStub(this);
//zum richtigen Layout hinzufügen
rl.addView(stub1);
stub1.setLayoutResource(R.layout.routen_navi_infocontent);
//Referenz zum eingefügten Layout herstellen
View inflated = stub1.inflate();
//Zugriff auf Inhalt des zufor referenzierten Layouts
TextView myTextView = (TextView) inflated.findViewById(R.id.tvHeaderInfocontent);
myTextView.setText("hey");
stub1.setId(View.generateViewId());
stub1.setInflatedId(stub1.getId());
RelativeLayout rlInf1 = (RelativeLayout) inflated.findViewById(R.id.Layout_infocontent);
ViewStub stub2 = new ViewStub(this);
//zum richtigen Layout hinzufügen
rl.addView(stub2);
stub2.setLayoutResource(R.layout.routen_navi_infocontent);
//Referenz zum eingefügten Layout herstellen
View inflated2 = stub2.inflate();
RelativeLayout rlInf2 = (RelativeLayout) inflated2.findViewById(R.id.Layout_infocontent);
RelativeLayout.LayoutParams p= new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
p.addRule(RelativeLayout.BELOW,rlInf1.getId());
rlInf2.setLayoutParams(p);