Same as my previous article on ListView attributes: Android – 0101 Attributes of ListView to keep in mind, here i am going to share about the attributes of GridView which we frequently use inside the application. Here are attributes:
Mostly Used:
0000 => android:numColumns=”auto_fit”
0001 => android:verticalSpacing=”5dp”
0010 => android:horizontalSpacing=”10dp”
0011 => android:stretchMode=”columnWidth”
0100 => android:columnWidth=”90dp”
0101 => android:smoothScrollbar=”true”
Rarely Used:
0110 => android:listSelector=”@color/red”
0111 => android:drawSelectorOnTop=”true”
1000 => android:scrollbarStyle=”insideOverlay”
1001 => android:scrollbars=”vertical”
0000. android:numColumns
Used to set number of columns we wants inside the GridView. we can also set “auto_fit” value so that we developer need not to bother about number of columns.
0001. android:verticalSpacing
Used to set spacing between two gridview items vertically.
0010. android:horizontalSpacing
Used to set spacing between two gridview items horizontally.
0011. andorid:stretchMode
Used to control how items are stretched to fill their space.
0100. android:columnWidth
Used to set Width of the Column.
0101. android:smoothScrollbar=”true”
Used to control scrollbar effectively and When set to true, the list will use a more refined calculation method based on the pixels height of the items visible on screen.
0110. android:listSelector=”@color/red”
Used to define the Selector image/color, selector image/color will be appeared whenever we focus/pressed on the GridView item.
0111. android:drawSelectorOnTop=”true”
Used to control the selector image/color and When set to true, the selector will be drawn over the selected item.
1000. android:scrollbarStyle=”insideOverlay”
Used to define the scroll bar position and its style.
1001. android:scrollbars=”vertical”
Used to define scrollbars such as Horizontal, vertical or both.
For example:
<GridView android:id="@+id/gridViewImages" android:layout_below="@+id/header" android:layout_height="match_parent" android:layout_width="fill_parent" android:numColumns="auto_fit" android:verticalSpacing="5dp" adroid:horizontalSpacing="10dp" android:smoothScrollbar="true"> </GridView>
For knowing more about GridView and its attributes, visit android sdk site: Android GridView.