ColumnCalculator
public
class
ColumnCalculator
extends Object
| java.lang.Object | |
| ↳ | androidx.car.util.ColumnCalculator |
Utility class that calculates the width of the columns that will fit on the screen. A column's width is determined by the size of the margins and gutters (space between the columns) that fit on-screen.
Refer to the appropriate dimens and integers for the size of the margins and number of columns.
The following is an example of the location and sizes of margins and gutters:
Summary
Public methods | |
|---|---|
int
|
getColumnCount()
Returns the total number of columns that fit on the current screen. |
int
|
getColumnSpanWidth(int columnSpan)
Returns the width in pixels that the given number of columns will span over. |
int
|
getColumnWidth()
Returns the size in pixels of each column. |
int
|
getGutterCount()
Returns the total number of gutters that fit on screen. |
int
|
getGutterWidth()
Returns the width of each gutter in pixels. |
static
ColumnCalculator
|
getInstance(Context context)
Gets an instance of the |
Inherited methods | |
|---|---|
Public methods
getColumnCount
public int getColumnCount ()
Returns the total number of columns that fit on the current screen.
| Returns | |
|---|---|
int |
The total number of columns that fit on the screen. |
getColumnSpanWidth
public int getColumnSpanWidth (int columnSpan)
Returns the width in pixels that the given number of columns will span over.
This value takes into account the size of the gutter between the columns as well. For example, for a column span of four, the size returned is the sum of four columns and three gutters.
| Parameters | |
|---|---|
columnSpan |
int |
| Returns | |
|---|---|
int |
The size in pixels for a given column span. |
getColumnWidth
public int getColumnWidth ()
Returns the size in pixels of each column. The column width is determined by the size of the screen divided by the number of columns, size of gutters and margins.
| Returns | |
|---|---|
int |
The width of a single column in pixels. |
getGutterCount
public int getGutterCount ()
Returns the total number of gutters that fit on screen. A gutter is the space between each column. This value is always one less than the number of columns.
| Returns | |
|---|---|
int |
The number of gutters on screen. |
getGutterWidth
public int getGutterWidth ()
Returns the width of each gutter in pixels. A gutter is the space between each column.
| Returns | |
|---|---|
int |
The width of a single gutter in pixels. |
getInstance
public static ColumnCalculator getInstance (Context context)
Gets an instance of the ColumnCalculator. If this is the first time that this
method has been called, then the given Context will be used to retrieve resources.
| Parameters | |
|---|---|
context |
Context: The current calling Context. |
| Returns | |
|---|---|
ColumnCalculator |
An instance of ColumnCalculator.
|