MaterialDivider

public class MaterialDivider
extends View

java.lang.Object
   ↳ android.view.View
     ↳ com.google.android.material.divider.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

XML attributes

MaterialDivider_dividerColor  
MaterialDivider_dividerInsetEnd  
MaterialDivider_dividerInsetStart  
MaterialDivider_dividerThickness  

Inherited constants

Inherited fields

Public constructors

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

Public methods

int getDividerColor()

Returns the divider color.

int getDividerInsetEnd()

Returns the divider's end inset.

int getDividerInsetStart()

Returns the divider's start inset.

int getDividerThickness()

Returns the app:dividerThickness set on the divider.

void setDividerColor(int color)

Sets the color of the divider.

void setDividerColorResource(int colorId)

Sets the color of the divider.

void setDividerInsetEnd(int insetEnd)

Sets the end inset of the divider.

void setDividerInsetEndResource(int insetEndId)

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)

Inherited methods

XML attributes

MaterialDivider_dividerColor

Related methods:

MaterialDivider_dividerInsetEnd

Related methods:

MaterialDivider_dividerInsetStart

Related methods:

MaterialDivider_dividerThickness

Related methods:

Public constructors

MaterialDivider

public MaterialDivider (Context context)

Parameters
context Context

MaterialDivider

public MaterialDivider (Context context, 
                AttributeSet attrs)

Parameters
context Context

attrs AttributeSet

MaterialDivider

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

Parameters
context Context

attrs AttributeSet

defStyleAttr int

Public methods

getDividerColor

public int getDividerColor ()

Returns the divider color.

Related XML Attributes:

Returns
int

getDividerInsetEnd

public int getDividerInsetEnd ()

Returns the divider's end inset.

Related XML Attributes:

Returns
int

getDividerInsetStart

public int getDividerInsetStart ()

Returns the divider's start inset.

Related XML Attributes:

Returns
int

getDividerThickness

public int getDividerThickness ()

Returns the app:dividerThickness set on the divider.

Related XML Attributes:

Returns
int

setDividerColor

public void setDividerColor (int color)

Sets the color of the divider.

Related XML Attributes:

Parameters
color int: The color to be set.

See also:

setDividerColorResource

public void setDividerColorResource (int colorId)

Sets the color of the divider.

Related XML Attributes:

Parameters
colorId int: The id of the color resource to be set.

See also:

setDividerInsetEnd

public void setDividerInsetEnd (int insetEnd)

Sets the end inset of the divider.

Related XML Attributes:

Parameters
insetEnd int: The end inset to be set.

setDividerInsetEndResource

public void setDividerInsetEndResource (int insetEndId)

Sets the end inset of the divider.

Related XML Attributes:

Parameters
insetEndId int: The id of the inset dimension resource to be set.

setDividerInsetStart

public void setDividerInsetStart (int insetStart)

Sets the start inset of the divider.

Related XML Attributes:

Parameters
insetStart int: The start inset to be set.

setDividerInsetStartResource

public void setDividerInsetStartResource (int insetStartId)

Sets the start inset of the divider.

Related XML Attributes:

Parameters
insetStartId int: 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.

Related XML Attributes:

Parameters
thickness int: 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.

Related XML Attributes:

Parameters
thicknessId int: The id of the thickness dimension resource to be set.

Protected methods

onDraw

protected void onDraw (Canvas canvas)

Parameters
canvas Canvas

onMeasure

protected void onMeasure (int widthMeasureSpec, 
                int heightMeasureSpec)

Parameters
widthMeasureSpec int

heightMeasureSpec int