Reputation: 769
i'm using the gridview to display the images.
<GridView
android:id="@+id/gridView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:columnWidth="96dp"
android:numColumns="auto_fit"
android:stretchMode="columnWidth" >
</GridView>
and the imageview is
<ImageView
android:id="@+id/imageView1"
android:layout_width="96dp"
android:layout_height="96dp"
android:background="@drawable/image_bg"
android:scaleType="fitXY"
android:src="@drawable/ic_launcher" />
Note : I dont want to hardcode the numbers of images to display in single row of gridview because if the screen orientation changed the number changes
When i'm loading m getting the space bewteen the images in the gridview as the below picture
But i dont need the space i want the gridview to appear like the native gallery
Upvotes: 0
Views: 65
Reputation: 2215
Change layout_width
android:layout_width="match-parent"
instead of "96dp"
Upvotes: 1
Reputation: 3993
add this to your gridview xml :
android:listSelector="@android:color/transparent"
and also try myGridView.setStretchMode(GridView.STRETCH_COLUMN_WIDTH);
Upvotes: 0
Reputation: 8939
Try using below tag in GridView
android:verticalSpacing="10dp" // changed this value
android:horizontalSpacing="10dp"
For reference HorizontalSpacing and VerticalSpacing
Upvotes: 0