one way is to use the anchor view that is inside your relative layout, set your button to the right of it and set the margin.
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" > <View android:id="@+id/anchor" android:layout_width="0dp" android:layout_height="0dp" android:layout_centerInParent="true" /> <ImageButton android:layout_width="100dp" android:layout_height="100dp" android:layout_marginRight="50dp" android:layout_toRightOf="@+id/anchor" /> </RelativeLayout>
or try:
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="center" > <ImageButton android:layout_width="100dp" android:layout_height="100dp" android:layout_marginRight="50dp" /> </RelativeLayout>
source share