Skip to content

Commit

Permalink
[NavigationRail][NavigationBar] Fixed active item focused state color…
Browse files Browse the repository at this point in the history
… not being visible.

The color state list used for the ripple to indicate focal/hover state was being set as the background of an item and being obscured by the active indicator. It is now the foreground and visible on top of the active indicator.

PiperOrigin-RevId: 515343383
  • Loading branch information
hunterstich authored and paulfthomas committed Mar 13, 2023
1 parent 22c4e0d commit 1d2a59b
Showing 1 changed file with 4 additions and 4 deletions.
Expand Up @@ -698,7 +698,7 @@ public void setItemRippleColor(@Nullable ColorStateList itemRippleColor) {
* is created and set.
*/
private void refreshItemBackground() {
Drawable iconContainerBackgroundDrawable = null;
Drawable iconContainerRippleDrawable = null;
Drawable itemBackgroundDrawable = itemBackground;
boolean defaultHighlightEnabled = true;

Expand All @@ -713,9 +713,9 @@ && getActiveIndicatorDrawable() != null
// Remove the default focus highlight that highlights the entire view and rely on the
// active indicator ripple to communicate state.
defaultHighlightEnabled = false;
// Set the icon container's background to a ripple masked by the active indicator's
// Set the icon container's foreground to a ripple masked by the active indicator's
// drawable.
iconContainerBackgroundDrawable =
iconContainerRippleDrawable =
new RippleDrawable(
RippleUtils.sanitizeRippleDrawableColor(itemRippleColor), null, maskDrawable);
} else if (itemBackgroundDrawable == null) {
Expand All @@ -727,7 +727,7 @@ && getActiveIndicatorDrawable() != null
// Check that this item includes an icon container. If a NavigationBarView's subclass supplies
// a custom item layout, this can be null.
if (iconContainer != null) {
ViewCompat.setBackground(iconContainer, iconContainerBackgroundDrawable);
iconContainer.setForeground(iconContainerRippleDrawable);
}
ViewCompat.setBackground(this, itemBackgroundDrawable);
if (VERSION.SDK_INT >= VERSION_CODES.O) {
Expand Down

0 comments on commit 1d2a59b

Please sign in to comment.