{"record":{"id":"8e90786cb62da481","repo":"material-components/material-components-android","slug":"changing-divider-drawables-have-no-effect-chipgro","errorCode":null,"errorMessage":"Changing divider drawables have no effect. ChipGroup do not use divider drawables as spacing.","messagePattern":"Changing divider drawables have no effect\\. ChipGroup do not use divider drawables as spacing\\.","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"lib/java/com/google/android/material/chip/ChipGroup.java","lineNumber":232,"sourceCode":"  public void setOnHierarchyChangeListener(OnHierarchyChangeListener listener) {\n    // the user listener is delegated to our pass-through listener\n    passThroughListener.onHierarchyChangeListener = listener;\n  }\n\n  @Override\n  protected void onFinishInflate() {\n    super.onFinishInflate();\n\n    // checks the appropriate chip as requested in the XML file\n    if (defaultCheckedId != View.NO_ID) {\n      checkableGroup.check(defaultCheckedId);\n    }\n  }\n\n  /** @deprecated Use {@link ChipGroup#setChipSpacingHorizontal(int)} instead. */\n  @Deprecated\n  public void setDividerDrawableHorizontal(Drawable divider) {\n    throw new UnsupportedOperationException(\n        \"Changing divider drawables have no effect. ChipGroup do not use divider drawables as \"\n            + \"spacing.\");\n  }\n\n  /** @deprecated Use {@link ChipGroup#setChipSpacingVertical(int)} instead. */\n  @Deprecated\n  public void setDividerDrawableVertical(@Nullable Drawable divider) {\n    throw new UnsupportedOperationException(\n        \"Changing divider drawables have no effect. ChipGroup do not use divider drawables as \"\n            + \"spacing.\");\n  }\n\n  /** @deprecated Use {@link ChipGroup#setChipSpacingHorizontal(int)} instead. */\n  @Deprecated\n  public void setShowDividerHorizontal(int dividerMode) {\n    throw new UnsupportedOperationException(\n        \"Changing divider modes has no effect. ChipGroup do not use divider drawables as spacing.\");\n  }","sourceCodeStart":214,"sourceCodeEnd":250,"githubUrl":"https://github.com/material-components/material-components-android/blob/ac7e18efeefb331850c561faf9ab8bf81d27ba68/lib/java/com/google/android/material/chip/ChipGroup.java#L214-L250","documentation":"ChipGroup is a FlowLayout, not a LinearLayout; spacing between chips is controlled by chipSpacingHorizontal/chipSpacingVertical, not divider drawables. The deprecated setDividerDrawableHorizontal throws UnsupportedOperationException to fail fast instead of silently ignoring the call. The javadoc directs you to setChipSpacingHorizontal.","triggerScenarios":"Calling chipGroup.setDividerDrawableHorizontal(drawable) on a ChipGroup; copying LinearLayout divider setup code onto a ChipGroup.","commonSituations":"Migrating a LinearLayout of buttons to ChipGroup and carrying over setDividerDrawable calls; Android Studio deprecation autofill picking the method without noticing it throws.","solutions":["Replace setDividerDrawableHorizontal(d) with chipGroup.setChipSpacingHorizontal(dp) or the app:chipSpacingHorizontal XML attribute.","If actual visual dividers are required, place them as separate child views instead."],"exampleFix":"// before\nchipGroup.setDividerDrawableHorizontal(divider) // throws\n\n// after\nchipGroup.setChipSpacingHorizontal(resources.getDimensionPixelOffset(R.dimen.chip_spacing))","handlingStrategy":"validation","validationCode":"fun setSpacing(group: ChipGroup, @Px horizontal: Int) {\n  group.chipSpacingHorizontal = horizontal // never call setDividerDrawableHorizontal\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["ChipGroup spacing comes only from chipSpacingHorizontal/chipSpacingVertical.","Delete all divider-drawable code paths when migrating LinearLayout to ChipGroup.","Treat @Deprecated + throws methods in this library as removed APIs, not soft warnings."],"tags":["android","material-components","chipgroup","deprecated","layout"],"backgroundTag":null,"analyzedSha":"ac7e18efeefb331850c561faf9ab8bf81d27ba68","analyzedAt":"2026-08-14T15:35:35.735Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}