# MaterialDivider

[View Source](https://github.com/material-components/material-components-android/blob/1.14.0/lib/java/com/google/android/material/divider/MaterialDivider.java)

*** ** * ** ***


```
public class MaterialDivider
```

<br />

*** ** * ** ***

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](https://github.com/material-components/material-components-android/blob/master/docs/components/Divider.md) and [design guidelines](https://material.io/components/divider/overview).

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/com/google/android/material/divider/MaterialDivider#MaterialDivider(Context)(Context context)` |
| `https://developer.android.com/reference/com/google/android/material/divider/MaterialDivider#MaterialDivider(Context,AttributeSet)(Context context, AttributeSet attrs)` |
| `https://developer.android.com/reference/com/google/android/material/divider/MaterialDivider#MaterialDivider(Context,AttributeSet,int)(Context context, AttributeSet attrs, int defStyleAttr)` |

| ### Public methods |
|---|---|
| `int` | `https://developer.android.com/reference/com/google/android/material/divider/MaterialDivider#getDividerColor()()` Returns the divider color. |
| `int` | `https://developer.android.com/reference/com/google/android/material/divider/MaterialDivider#getDividerInsetEnd()()` Returns the divider's end inset. |
| `int` | `https://developer.android.com/reference/com/google/android/material/divider/MaterialDivider#getDividerInsetStart()()` Returns the divider's start inset. |
| `int` | `https://developer.android.com/reference/com/google/android/material/divider/MaterialDivider#getDividerThickness()()` Returns the `app:dividerThickness` set on the divider. |
| `void` | `https://developer.android.com/reference/com/google/android/material/divider/MaterialDivider#setDividerColor(int)(int color)` Sets the color of the divider. |
| `void` | `https://developer.android.com/reference/com/google/android/material/divider/MaterialDivider#setDividerColorResource(int)(int colorId)` Sets the color of the divider. |
| `void` | `https://developer.android.com/reference/com/google/android/material/divider/MaterialDivider#setDividerInsetEnd(int)(int insetEnd)` Sets the end inset of the divider. |
| `void` | `https://developer.android.com/reference/com/google/android/material/divider/MaterialDivider#setDividerInsetEndResource(int)(int insetEndId)` Sets the end inset of the divider. |
| `void` | `https://developer.android.com/reference/com/google/android/material/divider/MaterialDivider#setDividerInsetStart(int)(int insetStart)` Sets the start inset of the divider. |
| `void` | `https://developer.android.com/reference/com/google/android/material/divider/MaterialDivider#setDividerInsetStartResource(int)(int insetStartId)` Sets the start inset of the divider. |
| `void` | `https://developer.android.com/reference/com/google/android/material/divider/MaterialDivider#setDividerThickness(int)(int thickness)` Sets the thickness of the divider. |
| `void` | `https://developer.android.com/reference/com/google/android/material/divider/MaterialDivider#setDividerThicknessResource(int)(int thicknessId)` Sets the thickness of the divider. |

| ### Protected methods |
|---|---|
| `void` | `https://developer.android.com/reference/com/google/android/material/divider/MaterialDivider#onDraw(Canvas)(Canvas canvas)` |
| `void` | `https://developer.android.com/reference/com/google/android/material/divider/MaterialDivider#onMeasure(int,int)(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 |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/divider/MaterialDivider#setDividerColor(int)` |   |

### getDividerInsetEnd

```
public int getDividerInsetEnd()
```

Returns the divider's end inset.

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

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/divider/MaterialDivider#setDividerInsetEnd(int)` |   |

### getDividerInsetStart

```
public int getDividerInsetStart()
```

Returns the divider's start inset.

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

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/divider/MaterialDivider#setDividerInsetStart(int)` |   |

### getDividerThickness

```
public int getDividerThickness()
```

Returns the `app:dividerThickness` set on the divider.

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

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/divider/MaterialDivider#setDividerThickness(int)` |   |

### 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 |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/divider/MaterialDivider#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 |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/divider/MaterialDivider#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. |

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/divider/MaterialDivider#getDividerInsetEnd()` |   |

### 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. |

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/divider/MaterialDivider#getDividerInsetEnd()` |   |

### 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. |

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/divider/MaterialDivider#getDividerInsetStart()` |   |

### 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. |

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/divider/MaterialDivider#getDividerInsetStart()` |   |

### 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. |

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/divider/MaterialDivider#getDividerThickness()` |   |

### 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. |

| See also |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/divider/MaterialDivider#getDividerThickness()` |   |

## Protected methods

### onDraw

```
protected void onDraw(Canvas canvas)
```

### onMeasure

```
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
```