Stay organized with collections
Save and categorize content based on your preferences.
Segment
class Segment
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 |
Create a segment with a non-zero length.
|
Public constructors
Segment
Segment(length: Int)
Create a segment with a non-zero length.
Public methods
equals
fun equals(other: Any?): Boolean
Needed for android.app.Notification.Style#areNotificationsVisiblyDifferent
Parameters |
obj |
the reference object with which to compare. |
Return |
Boolean |
true if this object is the same as the obj argument; false otherwise. |
getColor
fun getColor(): Int
Returns the color of this Segment.
getId
fun getId(): Int
Gets the id of this Segment.
getLength
fun getLength(): 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 ProgressStyle.setProgress
.
Return |
Int |
Value is 1 or greater |
hashCode
fun hashCode(): Int
Return |
Int |
a hash code value for this object. |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-08-20 UTC.
[null,null,["Last updated 2025-08-20 UTC."],[],[],null,["# Notification.ProgressStyle.Segment\n\nAdded in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nSegment\n=======\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/app/Notification.ProgressStyle.Segment \"View this page in Java\") \n\n```\nclass Segment\n```\n\n|---|-----------------------------------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||\n| ↳ | [android.app.Notification.ProgressStyle.Segment](#) |\n\nA 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.\n\nSummary\n-------\n\n| Public constructors ||\n|--------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|\n| [Segment](#Segment(kotlin.Int))`(`length:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Create a segment with a non-zero length. |\n\n| Public methods ||\n|------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | [equals](#equals(kotlin.Any))`(`other:` `[Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)?`)` Needed for android. |\n| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [getColor](#getColor())`()` Returns the color of this Segment. |\n| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [getId](#getId())`()` Gets the id of this Segment. |\n| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [getLength](#getLength())`()` The length of this Segment within the progress bar. |\n| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [hashCode](#hashCode())`()` \u003cbr /\u003e |\n| [Notification.ProgressStyle.Segment](#) | [setColor](#setColor(kotlin.Int))`(`color:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Optional color of this Segment |\n| [Notification.ProgressStyle.Segment](#) | [setId](#setId(kotlin.Int))`(`id:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Optional ID used to uniquely identify the element across updates. |\n\nPublic constructors\n-------------------\n\n### Segment\n\nAdded in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nSegment(length: Int)\n```\n\nCreate a segment with a non-zero length.\n\n| Parameters ||\n|----------|---------------------------------------------------------------------------------------------------------------------------------|\n| `length` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): See [getLength](#getLength()) Value is 1 or greater |\n\nPublic methods\n--------------\n\n### equals\n\nAdded in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun equals(other: Any?): Boolean\n```\n\nNeeded for android.app.Notification.Style#areNotificationsVisiblyDifferent\n\n| Parameters ||\n|-------|---------------------------------------------|\n| `obj` | the reference object with which to compare. |\n\n| Return ||\n|------------------------------------------------------------------------------------|---------------------------------------------------------------------------|\n| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | `true` if this object is the same as the obj argument; `false` otherwise. |\n\n### getColor\n\nAdded in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun getColor(): Int\n```\n\nReturns the color of this Segment. \n**See Also**\n\n- [#setColor](#setColor(kotlin.Int)) \n\n### getId\n\nAdded in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun getId(): Int\n```\n\nGets the id of this Segment. \n**See Also**\n\n- [#setId](#setId(kotlin.Int)) \n\n### getLength\n\nAdded in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun getLength(): Int\n```\n\nThe 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 [ProgressStyle.setProgress](/reference/kotlin/android/app/Notification.ProgressStyle#setProgress(kotlin.Int)).\n\n| Return ||\n|----------------------------------------------------------------------------|-----------------------|\n| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | Value is 1 or greater |\n\n### hashCode\n\nAdded in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun hashCode(): Int\n```\n\n| Return ||\n|----------------------------------------------------------------------------|------------------------------------|\n| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | a hash code value for this object. |\n\n### setColor\n\nAdded in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun setColor(color: Int): Notification.ProgressStyle.Segment\n```\n\nOptional color of this Segment\n\n| Return ||\n|-----------------------------------------|------------------------------|\n| [Notification.ProgressStyle.Segment](#) | This value cannot be `null`. |\n\n### setId\n\nAdded in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun setId(id: Int): Notification.ProgressStyle.Segment\n```\n\nOptional ID used to uniquely identify the element across updates. The default is 0.\n\n| Return ||\n|-----------------------------------------|------------------------------|\n| [Notification.ProgressStyle.Segment](#) | This value cannot be `null`. |"]]