HexGridView

class HexGridView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : ViewGroup

The View version of the library's hex grid.

HexGridView is a ViewGroup that can hold one child View for each cell. The group recognizes special layout attributes on its children to allow cell assignment and initialization in the layout XML. For example:

<com.gonodono.hexgrid.view.HexGridView …>

<Button

app:layout_cellRowAndColumn="1,1"
app:layout_cellIsSelected="true" />

</com.gonodono.hexgrid.view.HexGridView>

If the library's CellStateView is used instead of a regular View, no actual View object is added to the HexGridView, and the element is used only for the attribute settings.

The class also offers the ViewProvider interface as a way to assign Views in code instead. This method always overrides anything set in the layout XML for a given cell.

HexGridView offers its own OnClickListener interface and corresponding property for click callbacks, and the drawn grid's cosmetic values are all available as direct properties; e.g., strokeColor and showRowIndices.

A HexGridView's Grid is handled similarly to ListView's and RecyclerView's data sets: if the user modifies the Grid, the HexGridView needs to be notified to update itself. The only thing needed is a call to invalidate, so that's left to the user, rather than having a pointless alias function that does nothing else. That is, if you change a State in the Grid, you need to call invalidate() on the HexGridView afterward.

Constructors

Link copied to clipboard
constructor(context: Context, attrs: AttributeSet? = null)

Types

Link copied to clipboard
Link copied to clipboard
fun interface OnClickListener

Callback for click events.

Link copied to clipboard
fun interface ViewProvider

Interface through which to provide Views to be placed in each cell.

Properties

Link copied to clipboard

A read-only Map of the current child Views.

Link copied to clipboard

The HexGridView's current CrossMode.

Link copied to clipboard

Color of the cells' interior normally.

Link copied to clipboard

The HexGridView's current FitMode.

Link copied to clipboard
var grid: Grid

The HexGridView's current Grid, which defaults to an empty Grid.

Link copied to clipboard

The HexGridView's current HexOrientation.

Link copied to clipboard
Link copied to clipboard

Color of the cells' interior when its selected state is true.

Link copied to clipboard

Whether to show each cell's column index.

Link copied to clipboard

Whether to show each cell's row index.

Link copied to clipboard

Color of the cells' outlines.

Link copied to clipboard

The HexGridView's current stroke width.

Link copied to clipboard

The HexGridView's current ViewProvider.

Functions

Link copied to clipboard
open override fun addView(child: View?, index: Int, params: ViewGroup.LayoutParams?)
Link copied to clipboard
fun applyHexBackground(view: View, @ColorInt color: Int, inset: Float)

Modifies the passed View's LayoutParams to cause a HexDrawable background to be added or updated during layout.

Link copied to clipboard
Link copied to clipboard

Causes the HexGridView to re-layout and redraw.

Link copied to clipboard
open override fun onTouchEvent(event: MotionEvent): Boolean
Link copied to clipboard

Modifies the passed View's LayoutParams to remove any HexDrawable background that may be present.