View的父级当然必须是RelativeLayout.那你可以做
final RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); params.addRule(RelativeLayout.RIGHT_OF, R.id.imageView1); params.addRule(RelativeLayout.END_OF, R.id.imageView1);
并打电话
view.setLayoutParams(params);