Since

3.0.2 Layout calculation class for GridView. It behaves iOS’s UICollectionViewFlowLayout and Android’s StaggeredGridLayout.

spanCount and scrollDirection are 2 important parameters of this class.

If user sets scrollDirection to “vertical”, spanCount represents count of colons. For example; scrollDirection: vertical, spanCount: 2 means user can scroll vertically, object has 2 colons and width property of items are fixed numbers depends on colon count. If user sets scrollDirection to “horizontal”, spanCount represents count of rows. For example; scrollDirection: horizontal, spanCount : 2 means user can scroll horizontally, object has 2 rows and height property of items are fixed numbers depends on row count

Example

var layoutManager = new LayoutManager({
spanCount: 2,
scrollDirection: LayoutManager.ScrollDirection.VERTICAL
});

Hierarchy

Implemented by

Properties

nativeObject: { [key: string]: any }

Type declaration

  • [key: string]: any
android: Partial<{}>
spanCount: number

Gets/sets colon or row count depends on scrolling direction of layout. If vertical it represents colon, if horizontal it represent row count.

Property

= 1]

Android

Ios

Since

3.0.2

contentInset: Boundary

Gets/sets the custom distance that the content view is inset from the scroll view edges.

Property

= {top:0, left:0, bottom:0, right:0}]

Android

Ios

Since

3.0.2

scrollDirection: ScrollDirection

The scroll direction of GridView.

Property

= 0]

Android

Ios

Since

3.0.2

lineSpacing: number
itemSpacing: number

Events

onItemLength: null | ((length: number) => number)

User must return a length value for scrollDirection that user lays out the objects. If vertical, length value will be height of item. If horizontal, length value will be width of item.

onItemLength

Android

Ios

Since

3.0.2

Example

import LayoutManager from '@smartface/native/ui/layoutmanager';

const layoutManager = new LayoutManager();
layoutManager.on(LayoutManager.Events.ItemLength, (params) => {
console.info('onItemLength', params);
});
onFullSpan: null | ((type: number) => number)

This event used to define specified gridview item to fully occupy width/height based on direction. According to direction return value must be either desired height or width of gridview item. If the direction is UI.LayoutManager.ScrollDirection#VERTICAL VERTICAL then return value must be height or vice versa. Returning undefined indicates that the gridview item will not modified.

onFullSpan

Android

Ios

Since

4.0.1

Example

import LayoutManager from '@smartface/native/ui/layoutmanager';

const layoutManager = new LayoutManager();
layoutManager.on(LayoutManager.Events.FullSpan, (params) => {
console.info('onFullSpan', params);
});

Generated using TypeDoc