0
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal"
    android:background="#FFFFFF"
    android:layout_gravity="center"
    android:padding="5dip" >
    <GridView
        android:id="@+id/homeGridView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:columnWidth="200dip"
        android:adjustViewBounds="true" 
        android:layout_gravity="center"
        android:gravity="center"
        android:horizontalSpacing="0dip"
        android:numColumns="2"
        android:stretchMode="none"
        android:verticalSpacing="@dimen/grid_vertical_space" />
</LinearLayout>

How to make the GridView center of the device?

theJava
  • 14,620
  • 45
  • 131
  • 172
  • I can see android:layout_gravity="center" and android:gravity="center" is already added to the view. what is the output you get on the screen? have you tried android:horizontalSpacing ? – D'yer Mak'er Mar 22 '13 at 11:02
  • If you can, provide us a screenshot of your layout with data/image. – JJ86 Mar 22 '13 at 12:32
  • @JaAd: Can you look on this thread... http://stackoverflow.com/questions/15570372/making-the-gridview-center-in-android – theJava Mar 22 '13 at 12:34

2 Answers2

1

Use Relative Layout instead of Linear Layout and apply android:layout_centerInParent="true" in your Gird View

Mansi
  • 1,939
  • 4
  • 22
  • 40
0

Did you tried to set your Gridview's android:layout_width and android:layout_height to wrap_content?

Damien R.
  • 3,383
  • 1
  • 21
  • 32