Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android GridView with Separator

is possible to have a separator between elements of a GridView?

Thanks

like image 562
Gerardo Avatar asked Mar 04 '10 21:03

Gerardo


People also ask

What is GridView in Android?

GridView Tutorial With Examples In Android In android GridView is a view group that display items in two dimensional scrolling grid (rows and columns), the grid items are not necessarily predetermined but they are automatically inserted to the layout using a ListAdapter. Users can then select any grid item by clicking on it.

What is listadapter in Android GridView?

Android GridView shows items in two-dimensional scrolling grid (rows & columns) and the grid items are not necessarily predetermined but they automatically inserted to the layout using a ListAdapter. An adapter actually bridges between UI components and the data source that fill data into UI Component.

What is the difference between GridView and staggered GridView?

GridView: A ViewGroup that shows the items in a two-dimensional scrolling grid. In Grid View, each grid is of the same size .i.e., the height and width of each grid are equal. It shows symmetric items in the views. Staggered GridView: This ViewGroup is the extension of Grid View.

How to use base adapter in Android GridView?

GridView Using Base Adapter In Android: Base Adapter is a common base class of a general implementation of an Adapter that can be used in GridView. Whenever you need a customized grid view you create your own adapter and extend base adapter in that. Base Adapter can be extended to create a custom Adapter for displaying custom grid items.


2 Answers

You'll probably have to play with padding and background colors. Set the background for the table to one color, and the background to each View in the table to another color. Set a 1 or 2 pixel padding around each View in the table, and you should have a border between.

like image 144
Jeff Barger Avatar answered Nov 09 '22 15:11

Jeff Barger


from @FreewheelNat's comment, "In your xml for your GridView, use android:horizontalSpacing="1dp" and android:verticalSpacing="1dp" to set a 1 (density independent) pixel padding around each cell for example. "

this is a much better solution than @Jeff Barger's

like image 38
Tyler Davis Avatar answered Nov 09 '22 14:11

Tyler Davis