Closed shifatul-i closed 7 years ago
Implementing this requires a completely different library. Thankfully, what you are looking for already exists :D https://github.com/Mauker1/MaterialSearchView https://github.com/claudiodegio/MsvSearch https://material.uplabs.com/posts/searchview
Hope this helps :+1:
Just hide the toolbar when the searchview gets focus and show the toolbar again when it loses focus. I do this by animating the toolbar up and down. It's not that hard.
public void hideToolbar() {
final RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mToolbar.getLayoutParams();
ValueAnimator animator = ValueAnimator.ofInt(params.topMargin, -mToolbar.getHeight());
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
params.topMargin = (Integer) valueAnimator.getAnimatedValue();
mToolbar.requestLayout();
}
});
animator.setDuration(Constants.MOVE_ANIMATION_DURATION);
animator.start();
}
public void showToolbar() {
final RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mToolbar.getLayoutParams();
ValueAnimator animator = ValueAnimator.ofInt(params.topMargin, 0);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
params.topMargin = (Integer) valueAnimator.getAnimatedValue();
mToolbar.requestLayout();
}
});
animator.setDuration(Constants.MOVE_ANIMATION_DURATION);
animator.start();
}
Please take a look at Google Play Store (Top Chart) page I think this will be a great addition to the library to be able to Collapse / Hide Floatingsearchview
Below are some sample images