how to set the alignment of views in the relative layout using java code in android
I know how to do in XML
android:layout_alignLeft="@id/button1"
android:layout_alignParentLeft="@id/button2"
but, I want to know how to write using java code? My Problem is to I want to align one TextView to right and ImageView to left inside a RelativeLayout. How to do that?