I need to center grid view horizontally in my android layout.xml. I have searched google for quite a while but didnt succeed in finding an answer.
I can only change
Set the stretch mode to columnWidth on your GridView layout or style:
android:stretchMode="columnWidth"
The column width will stretch to fill the available space. You can wrap your grid items in a transparent container that will stretch evenly while preserving the width of your visible content. The android:columnWidth attribute will function as "minimum column width." This also works with android:numColumns=auto_fit, android:horizontalSpacing and android:verticalSpacing.
Depending on what your grid items are you may not want to add a transparent container around your content. If you don't, the content width will stretch evenly which may actually look better on more devices.