This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Copyright 2020 Google LLC. | |
SPDX-License-Identifier: Apache-2.0 --> | |
<!-- In res/values/shape.xml --> | |
<style name="ShapeAppearanceOverlay.App.Image" parent=""> | |
<item name="cornerSize">0dp</item> | |
<item name="cornerSizeTopLeft">50%</item> | |
</style> | |
<!-- In layout --> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Copyright 2020 Google LLC. | |
SPDX-License-Identifier: Apache-2.0 */ | |
class AppCustomView ... { | |
... | |
private lateinit var materialShapeDrawable: MaterialShapeDrawable | |
override fun setElevation(elevation: Float) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Copyright 2020 Google LLC. | |
SPDX-License-Identifier: Apache-2.0 --> | |
<!-- In res/values/attrs.xml --> | |
<declare-styleable name="AppCustomView"> | |
<attr name="shapeAppearance" /> | |
... | |
</declare-styleable> | |
<!-- In res/values/styles.xml --> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Copyright 2020 Google LLC. | |
SPDX-License-Identifier: Apache-2.0 */ | |
// Set corner interpolation to half of current cornerSize(s) | |
msd.setInterpolation(0.5f) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Copyright 2020 Google LLC. | |
SPDX-License-Identifier: Apache-2.0 */ | |
/** | |
* Set shadow compat mode to be one of: | |
* - SHADOW_COMPAT_MODE_DEFAULT: Use platform rendering on API 21+, else compat rendering | |
* - SHADOW_COMPAT_MODE_NEVER: Use platform rendering always | |
* - SHADOW_COMPAT_MODE_ALWAYS: Use compay rendering always | |
*/ | |
msd.setShadowCompatibilityMode(shadowMode) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Copyright 2020 Google LLC. | |
SPDX-License-Identifier: Apache-2.0 */ | |
// Initialize elevation overlays | |
msd.initializeElevationOverlay(context) | |
// Pass elevation value to MSD to apply overlay (in dark theme) | |
msd.setElevation(elevation) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Copyright 2020 Google LLC. | |
SPDX-License-Identifier: Apache-2.0 */ | |
// Fill color | |
msd.setFillColor(fillColorStateList) | |
// Stroke color | |
msd.setStrokeColor(strokeColorStateList) | |
// Stroke width | |
msd.setStrokeWidth(strokeWidthDimension) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Copyright 2020 Google LLC. | |
SPDX-License-Identifier: Apache-2.0 */ | |
// Default constructor | |
val msd = MaterialShapeDrawable() | |
// ShapeAppearanceModel constructor | |
val msdFromSam = MaterialShapeDrawable(shapeAppearanceModel) | |
// Style/attr resources constructor (reads shapeAppearance and shapeAppearanceOverlay) | |
val msdFromStyles = MaterialShapeDrawable(context, attrs, defStyleAttr, defStyleRes) | |
// Cast from widget background |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Copyright 2020 Google LLC. | |
SPDX-License-Identifier: Apache-2.0 --> | |
<!-- In res/values/themes.xml --> | |
<style name="Theme.App.Base" parent="Theme.MaterialComponents.*"> | |
... | |
<item name="shapeAppearanceSmallComponent"> | |
@style/ShapeAppearance.App.SmallComponent | |
</item> | |
<item name="shapeAppearanceMediumComponent"> |
NewerOlder