Skip to content

Commit

Permalink
[NavigationView] Support for shapeAppearance and shapeAppearanceOverl…
Browse files Browse the repository at this point in the history
…ay attributes

Resolves #1535

GIT_ORIGIN_REV_ID=f676794634c788fb906bc36c0feadb1628e36fb4
PiperOrigin-RevId: 323783155
  • Loading branch information
gabrielemariotti authored and dsn5ft committed Jul 29, 2020
1 parent 70d659d commit e6f05bc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,10 @@ public NavigationView(@NonNull Context context, @Nullable AttributeSet attrs, in
// Set the background to a MaterialShapeDrawable if it hasn't been set or if it can be converted
// to a MaterialShapeDrawable.
if (getBackground() == null || getBackground() instanceof ColorDrawable) {
ShapeAppearanceModel shapeAppearanceModel =
ShapeAppearanceModel.builder(context, attrs, defStyleAttr, DEF_STYLE_RES).build();
Drawable orig = getBackground();
MaterialShapeDrawable materialShapeDrawable = new MaterialShapeDrawable();
MaterialShapeDrawable materialShapeDrawable = new MaterialShapeDrawable(shapeAppearanceModel);
if (orig instanceof ColorDrawable) {
materialShapeDrawable.setFillColor(
ColorStateList.valueOf(((ColorDrawable) orig).getColor()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,12 @@
<!-- Fill color for the item background shape. Used if itemBackground isn't set and there is an
itemShapeAppearance or itemShapeAppearanceOverlay. -->
<attr name="itemShapeFillColor" format="color"/>
<!-- Shape appearance style reference for NavigationView. Attribute declaration is in the Shape
package. -->
<attr name="shapeAppearance"/>
<!-- Shape appearance overlay style reference for NavigationView. To be used to augment
attributes declared in the shapeAppearance. Attribute declaration is in the Shape package.
-->
<attr name="shapeAppearanceOverlay"/>
</declare-styleable>
</resources>

0 comments on commit e6f05bc

Please sign in to comment.