Skip to content

Instantly share code, notes, and snippets.

@ricknout
Last active August 25, 2020 18:04
Show Gist options
  • Save ricknout/9610e27aa1e1e48d3560289aa4e2534d to your computer and use it in GitHub Desktop.
Save ricknout/9610e27aa1e1e48d3560289aa4e2534d to your computer and use it in GitHub Desktop.
MDC-Android ShapeAppearanceModel instantiation
/* Copyright 2020 Google LLC.
SPDX-License-Identifier: Apache-2.0 */
// Default builder
val sam = ShapeAppearanceModel.builder()
.setAllCorners(CornerFamily.CUT, cornerSize)
// Also setTopRightCorner, setAllEdges, etc.
.build()
// Style/attr resources builder (reads shapeAppearance and shapeAppearanceOverlay)
val samFromStyles = ShapeAppearanceModel.builder(context, attrs, defStyleAttr, defStyleRes)
.build()
// Build from existing ShapeAppearanceModel
val samFromExisting = sam.toBuilder()
...
.build()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment