Some links here1 and here2
this is what you need to do:
Create a RelativeLayout.LayoutParams object. To add rules, use addRule (int) or addRule (int, int). The first method is used to add rules that do not require values. Set the parameters for the presentation (in this case, for each button).
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); params.addRule(RelativeLayout.ALIGN_PARENT_LEFT,RelativeLayout.TRUE); yourView.setLayoutParams(params);
source share