How to fill a GridView with vertical images (rectangles), keep the gridview autofit so that it choose the good number of columns by itself.
here is my grid view and the cell :
<GridView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:gravity="center"
android:horizontalSpacing="@dimen/margin_medium"
android:numColumns="auto_fit"
android:overScrollMode="never"
android:paddingLeft="@dimen/margin_large" <!-- 16dp -->
android:paddingRight="@dimen/margin_large"
android:paddingTop="@dimen/margin_large"
android:scrollbars="none"
android:stretchMode="columnWidth"
android:verticalSpacing="@dimen/margin_medium" > <!-- 8dp -->
</GridView>
The Cell
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="@dimen/grid_cell_width" <!-- 359dp -->
android:layout_height="@dimen/grid_cell_height" <!-- 600dp -->
android:background="@drawable/selector_list_simple"
android:padding="@dimen/margin_small" > <!-- 4dp -->
<ImageView
android:id="@+id/cell_allzic_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:scaleType="centerInside" >
</ImageView>
<ProgressBar
android:id="@+id/cell_allzic_loading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:indeterminate="true"
android:indeterminateDrawable="@drawable/progress_bar_custom"
android:visibility="gone" />
</RelativeLayout>