android:layout_alignParentRight="true" LayoutParams lp = new LayoutParams(mp); lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);