Android setLayoutParams - ythy/blog GitHub Wiki
举例:
RelativeLayout.LayoutParams lps = new RelativeLayout.LayoutParams(llmain.getMeasuredWidth()
, RelativeLayout.LayoutParams.WRAP_CONTENT);
lps.addRule(RelativeLayout.BELOW, R.id.ll_main);
lps.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE);
this.handview.setLayoutParams(lps);
RelativeLayout.LayoutParams的类型RelativeLayout是handview父容器的类型setLayoutParams执行后 ,handview原有的位置属性值会被覆盖掉, 需要通过addRule来再次设置