本文地址:http://blog.csdn.net/u011181236/article/details/51455360
RelativeLayout l = new RelativeLayout(getContext());
RelativeLayout.LayoutParams rl =
new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
rl.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
imgSwitch.setLayoutParams(rl);