I dynamically add views to the relative layout and programmatically define them. Views can be moved around the screen to change their position.
When I try to set the view (button2) to sit below another view (button1), button2 is placed in the old location of button1 (the default location is where the views are added before moving). I linked the images to hope to convey this better.
This is the layout of the original. 
Layout after clicking Button2 
I have a LinkedList link tracking all view changes and presentation attributes for the layout, if that matters.
Here are the code functions:
How do I redefine Button1:
Buttons b = (Buttons) viewIndex; positioningLayout = new RelativeLayout.LayoutParams(b.getLayoutParams()); positioningLayout.addRule(RelativeLayout.CENTER_VERTICAL); b.setLayoutParams(positioningLayout); baseLayout.addView(b);
Moving views under a different kind of code snippet:
Buttons b = (Buttons) viewIndex; positioningLayout = new RelativeLayout.LayoutParams(b.getLayoutParams()); positioningLayout.addRule(RelativeLayout.BELOW, viewIdFromList.intValue()); b.setLayoutParams(positioningLayout); b.invalidate();
How do I add views to the layout.
uiList.addView(new Buttons(this), "BUTTON"); setDialogView(uiList.getLast()); showDialog(SET_ID); reloadUI();
setDialogView simply passes the view to Dialog SET_ID so that I can manually assign an ID for the view (for testing). reloadUI () simply finds the last view added to the LinkedList background and adds it to relativeLayout using .addView;
If you need more code, please let me know. Am I missing a call to update view layouts after making changes to relativeLayout child views? It seems that the view becomes visually positioned, but the actual LayoutParams are not updated, so when you set Button2 to Button1, it gets the old position.
Is there a way to force the relative position of the view to be set?