# NotificationCompat.ProgressStyle.Segment

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/app/NotificationCompat.java+class:androidx.core.app.NotificationCompat.ProgressStyle.Segment) Added in [1.17.0](https://developer.android.com/jetpack/androidx/releases/core#1.17.0)

*** ** * ** ***


```
class NotificationCompat.ProgressStyle.Segment
```

<br />

*** ** * ** ***

A segment of the progress bar, which defines its length and color. Segments allow for creating progress bars with multiple colors or sections to represent different stages or categories of progress. For example, Traffic conditions along a navigation journey.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.ProgressStyle.Segment#Segment(int)(length: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 1) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Create a segment with a non-zero length. |

| ### Public functions |
|---|---|
| `@https://developer.android.com/reference/kotlin/androidx/annotation/ColorInt https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.ProgressStyle.Segment#getColor()()` Returns the color of this Segment. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.ProgressStyle.Segment#getId()()` Gets the id of this Segment. |
| `@https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 1) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.ProgressStyle.Segment#getLength()()` The length of this Segment within the progress bar. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.ProgressStyle.Segment#getSemanticStyle()()` Returns the semantics applied to the Segment. |
| `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.ProgressStyle.Segment` | `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.ProgressStyle.Segment#setColor(int)(color: @https://developer.android.com/reference/kotlin/androidx/annotation/ColorInt https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Optional color of this Segment |
| `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.ProgressStyle.Segment` | `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.ProgressStyle.Segment#setId(int)(id: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Optional ID used to uniquely identify the element across updates. |
| `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.ProgressStyle.Segment` | `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.ProgressStyle.Segment#setSemanticStyle(int)(semanticStyle: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Applies semantics to the Segment. |

## Public constructors

### Segment

Added in [1.17.0](https://developer.android.com/jetpack/androidx/releases/core#1.17.0)

```
Segment(length: @IntRange(from = 1) Int)
```

Create a segment with a non-zero length.

| Parameters |
|---|---|
| `length: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 1) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | See `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.ProgressStyle.Segment#getLength()` |

## Public functions

### getColor

Added in [1.17.0](https://developer.android.com/jetpack/androidx/releases/core#1.17.0)

```
fun getColor(): @ColorInt Int
```

Returns the color of this Segment.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.ProgressStyle.Segment#setColor(int)` |   |
| `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat#COLOR_DEFAULT()` | for the default visual behavior when it is not set. |

### getId

Added in [1.17.0](https://developer.android.com/jetpack/androidx/releases/core#1.17.0)

```
fun getId(): Int
```

Gets the id of this Segment.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.ProgressStyle.Segment#setId(int)` |   |

### getLength

Added in [1.17.0](https://developer.android.com/jetpack/androidx/releases/core#1.17.0)

```
fun getLength(): @IntRange(from = 1) Int
```

The length of this Segment within the progress bar. This value has no units, it is just relative to the length of other segments, and the value provided to `https://developer.android.com/reference/kotlin/androidx/core/app/NotificationCompat.ProgressStyle#setProgress(int)`.

### getSemanticStyle

Added in [1.19.1](https://developer.android.com/jetpack/androidx/releases/core#1.19.1)

```
fun getSemanticStyle(): Int
```

Returns the semantics applied to the Segment. When the notification `https://developer.android.com/reference/android/app/Notification.html#FLAG_PROMOTED_ONGOING` this value is used to style (e.g. color) the segment.

### setColor

Added in [1.17.0](https://developer.android.com/jetpack/androidx/releases/core#1.17.0)

```
fun setColor(color: @ColorInt Int): NotificationCompat.ProgressStyle.Segment
```

Optional color of this Segment

### setId

Added in [1.17.0](https://developer.android.com/jetpack/androidx/releases/core#1.17.0)

```
fun setId(id: Int): NotificationCompat.ProgressStyle.Segment
```

Optional ID used to uniquely identify the element across updates. The default is 0.

### setSemanticStyle

Added in [1.19.1](https://developer.android.com/jetpack/androidx/releases/core#1.19.1)

```
fun setSemanticStyle(semanticStyle: Int): NotificationCompat.ProgressStyle.Segment
```

Applies semantics to the Segment. When the notification `https://developer.android.com/reference/android/app/Notification.html#FLAG_PROMOTED_ONGOING` this value is used to style (e.g. color) the segment.

If an app specifies *both* color and semantic style, the color overrides the style.