Skip to content

Commit e035f38

Browse files
imhappipaulfthomas
authored andcommitted
[SearchBar][SearchView] Set alpha for toolbar button directly rather than setting through a FadeThroughDrawable
PiperOrigin-RevId: 735925620
1 parent 0c83f50 commit e035f38

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

lib/java/com/google/android/material/search/SearchViewAnimationHelper.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,11 +458,25 @@ private void addBackButtonProgressAnimatorIfNeeded(AnimatorSet animatorSet) {
458458
if (searchView.isAnimatedNavigationIcon()) {
459459
addDrawerArrowDrawableAnimatorIfNeeded(animatorSet, drawable);
460460
addFadeThroughDrawableAnimatorIfNeeded(animatorSet, drawable);
461+
addBackButtonAnimatorIfNeeded(animatorSet, backButton);
461462
} else {
462463
setFullDrawableProgressIfNeeded(drawable);
463464
}
464465
}
465466

467+
private void addBackButtonAnimatorIfNeeded(AnimatorSet animatorSet, ImageButton backButton) {
468+
// If there's no navigation icon on the search bar, we should set the alpha for the button
469+
// itself instead of the drawables since the button background has a ripple.
470+
if (searchBar == null || searchBar.getNavigationIcon() != null) {
471+
return;
472+
}
473+
474+
ValueAnimator animator = ValueAnimator.ofFloat(0, 1);
475+
animator.addUpdateListener(
476+
animation -> backButton.setAlpha((Float) animation.getAnimatedValue()));
477+
animatorSet.playTogether(animator);
478+
}
479+
466480
private void addDrawerArrowDrawableAnimatorIfNeeded(AnimatorSet animatorSet, Drawable drawable) {
467481
if (drawable instanceof DrawerArrowDrawable) {
468482
DrawerArrowDrawable drawerArrowDrawable = (DrawerArrowDrawable) drawable;

0 commit comments

Comments
 (0)