I have simple layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<GridView
android:id="@+id/photo_browser_grid_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:gravity="center"
android:horizontalSpacing="5dp"
android:verticalSpacing="5dp"
android:stretchMode="none"
android:numColumns="auto_fit"
android:columnWidth="100dp">
</GridView>
I want to centre my GridView inside Relative layout. My spacing is always fixed. In result I have GridView aligned to left. How can I center it inside parent?

For GridView in the layout,
android:numColumns="auto_fit"conflicts withandroid:layout_width="wrap_content". It means : to calculate how many columns to form, width is required, but to find width we need how many columns to wrap around, a circular dependency.You can use
android:stretchModeto let columns fill up empty space.