MaterialDivider

public class MaterialDivider


A Material divider view.

The divider will display the correct default Material colors without the use of a style flag in a layout file. Make sure to set android:layout_height="wrap_content" to ensure that the correct thickness is set for the divider.

For more information, see the component developer guidance and design guidelines.

Summary

Public constructors

MaterialDivider(Context context)
MaterialDivider(Context context, AttributeSet attrs)
MaterialDivider(Context context, AttributeSet attrs, int defStyleAttr)

Public methods

int

Returns the divider color.

int

Returns the divider's end inset.

int

Returns the divider's start inset.

int

Returns the app:dividerThickness set on the divider.

void
setDividerColor(int color)

Sets the color of the divider.

void

Sets the color of the divider.

void
setDividerInsetEnd(int insetEnd)

Sets the end inset of the divider.

void

Sets the end inset of the divider.

void
setDividerInsetStart(int insetStart)

Sets the start inset of the divider.

void
setDividerInsetStartResource(int insetStartId)

Sets the start inset of the divider.

void
setDividerThickness(int thickness)

Sets the thickness of the divider.

void
setDividerThicknessResource(int thicknessId)

Sets the thickness of the divider.

Protected methods

void
onDraw(Canvas canvas)
void
onMeasure(int widthMeasureSpec, int heightMeasureSpec)

Public constructors

MaterialDivider

public MaterialDivider(Context context)

MaterialDivider

public MaterialDivider(Context context, AttributeSet attrs)

MaterialDivider

public MaterialDivider(Context context, AttributeSet attrs, int defStyleAttr)

Public methods

getDividerColor

public int getDividerColor()

Returns the divider color.

ref com.google.android.material.R.styleable#MaterialDivider_dividerColor

See also
setDividerColor

getDividerInsetEnd

public int getDividerInsetEnd()

Returns the divider's end inset.

ref com.google.android.material.R.styleable#MaterialDivider_dividerInsetEnd

getDividerInsetStart

public int getDividerInsetStart()

Returns the divider's start inset.

ref com.google.android.material.R.styleable#MaterialDivider_dividerInsetStart

getDividerThickness

public int getDividerThickness()

Returns the app:dividerThickness set on the divider.

ref com.google.android.material.R.styleable#MaterialDivider_dividerThickness

setDividerColor

public void setDividerColor(int color)

Sets the color of the divider.

ref com.google.android.material.R.styleable#MaterialDivider_dividerColor

Parameters
int color

The color to be set.

See also
getDividerColor

setDividerColorResource

public void setDividerColorResource(int colorId)

Sets the color of the divider.

ref com.google.android.material.R.styleable#MaterialDivider_dividerColor

Parameters
int colorId

The id of the color resource to be set.

See also
getDividerColor

setDividerInsetEnd

public void setDividerInsetEnd(int insetEnd)

Sets the end inset of the divider.

ref com.google.android.material.R.styleable#MaterialDivider_dividerInsetEnd

Parameters
int insetEnd

The end inset to be set.

setDividerInsetEndResource

public void setDividerInsetEndResource(int insetEndId)

Sets the end inset of the divider.

ref com.google.android.material.R.styleable#MaterialDivider_dividerInsetEnd

Parameters
int insetEndId

The id of the inset dimension resource to be set.

setDividerInsetStart

public void setDividerInsetStart(int insetStart)

Sets the start inset of the divider.

ref com.google.android.material.R.styleable#MaterialDivider_dividerInsetStart

Parameters
int insetStart

The start inset to be set.

setDividerInsetStartResource

public void setDividerInsetStartResource(int insetStartId)

Sets the start inset of the divider.

ref com.google.android.material.R.styleable#MaterialDivider_dividerInsetStart

Parameters
int insetStartId

The id of the inset dimension resource to be set.

setDividerThickness

public void setDividerThickness(int thickness)

Sets the thickness of the divider. The divider's android:layout_height must be set to wrap_content in order for this value to be respected.

ref com.google.android.material.R.styleable#MaterialDivider_dividerThickness

Parameters
int thickness

The thickness value to be set.

setDividerThicknessResource

public void setDividerThicknessResource(int thicknessId)

Sets the thickness of the divider. The divider's android:layout_height must be set to wrap_content in order for this value to be respected.

ref com.google.android.material.R.styleable#MaterialDivider_dividerThickness

Parameters
int thicknessId

The id of the thickness dimension resource to be set.

Protected methods

onDraw

protected void onDraw(Canvas canvas)

onMeasure

protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)