{"record":{"id":"6c1f5eff5bce7e83","repo":"material-components/material-components-android","slug":"the-inactive-and-active-parts-of-the-track-are-dif","errorCode":null,"errorMessage":"The inactive and active parts of the track are different colors. Use the getInactiveTrackColor() and getActiveTrackColor() methods instead.","messagePattern":"The inactive and active parts of the track are different colors\\. Use the getInactiveTrackColor\\(\\) and getActiveTrackColor\\(\\) methods instead\\.","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"lib/java/com/google/android/material/slider/BaseSlider.java","lineNumber":1998,"sourceCode":"    }\n  }\n\n  /**\n   * Returns the color of the track if the active and inactive parts aren't different.\n   *\n   * @throws IllegalStateException If {@code trackColorActive} and {@code trackColorInactive} have\n   *     been set to different values.\n   * @see #setTrackTintList(ColorStateList)\n   * @see #setTrackInactiveTintList(ColorStateList)\n   * @see #setTrackActiveTintList(ColorStateList)\n   * @see #getTrackInactiveTintList()\n   * @see #getTrackActiveTintList()\n   * @attr ref com.google.android.material.R.styleable#Slider_trackColor\n   */\n  @NonNull\n  public ColorStateList getTrackTintList() {\n    if (!trackColorInactive.equals(trackColorActive)) {\n      throw new IllegalStateException(\n          \"The inactive and active parts of the track are different colors. Use the\"\n              + \" getInactiveTrackColor() and getActiveTrackColor() methods instead.\");\n    }\n    return trackColorActive;\n  }\n\n  /**\n   * Sets the color of the track.\n   *\n   * @see #setTrackInactiveTintList(ColorStateList)\n   * @see #setTrackActiveTintList(ColorStateList)\n   * @see #getTrackTintList()\n   * @attr ref com.google.android.material.R.styleable#Slider_trackColor\n   */\n  public void setTrackTintList(@NonNull ColorStateList trackColor) {\n    setTrackInactiveTintList(trackColor);\n    setTrackActiveTintList(trackColor);\n  }","sourceCodeStart":1980,"sourceCodeEnd":2016,"githubUrl":"https://github.com/material-components/material-components-android/blob/ac7e18efeefb331850c561faf9ab8bf81d27ba68/lib/java/com/google/android/material/slider/BaseSlider.java#L1980-L2016","documentation":"IllegalStateException thrown by getTrackTintList() when trackColorInactive and trackColorActive differ. As with ticks, the combined getter is only valid when both track halves share one ColorStateList; otherwise use getTrackInactiveTintList() and getTrackActiveTintList().","triggerScenarios":"Setting app:trackColorInactive and app:trackColorActive to different colors (or setTrackInactiveTintList(a)/setTrackActiveTintList(b)), then calling getTrackTintList().","commonSituations":"Material theming that deliberately differentiates the played vs remaining track (e.g. media seek bars) while shared UI code calls the unified getter; generic tint-inspection helpers.","solutions":["Use getTrackInactiveTintList() and getTrackActiveTintList() for the two halves.","If one color is intended, call setTrackTintList(color) so both fields are set together.","Audit shared style code that assumes getTrackTintList() never throws."],"exampleFix":"// before\nColorStateList track = slider.getTrackTintList(); // throws when halves differ\n\n// after\nColorStateList inactive = slider.getTrackInactiveTintList();\nColorStateList active = slider.getTrackActiveTintList();","handlingStrategy":"validation","validationCode":"ColorStateList inactive = slider.getTrackInactiveTintList();\nColorStateList active = slider.getTrackActiveTintList();\n// avoid getTrackTintList() unless both were set via setTrackTintList()","typeGuard":null,"tryCatchPattern":"In shared helpers: try { cs = slider.getTrackTintList(); } catch (IllegalStateException e) { cs = slider.getTrackActiveTintList(); }","preventionTips":["Use the split getters when themes differentiate track halves.","Use setTrackTintList() (combined) when one color is intended."],"tags":["android","slider","material-components","color","api-misuse"],"backgroundTag":null,"analyzedSha":"ac7e18efeefb331850c561faf9ab8bf81d27ba68","analyzedAt":"2026-08-14T15:35:35.735Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}