You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I notice that when the search icon is being clicked for the first time, animation effect is not visible. The animation effect will only be visible for 2nd time.
I look at the source code. However, I have no idea why there's such strange behavior.
Thank you
The text was updated successfully, but these errors were encountered:
I think the reason is that, when first time click is being performed, searchtoolbar is not inflated yet. Hence, its dimension is not available. I would suggest using the following way to obtain width, cx and cy, which is more reliable. Especially for some menu item with ifRoom, it is difficult to pick a correct posFromRight value.
private int getActionSearchMenuLocation() {
View menuSearch = findViewById(R.id.action_search);
// Found it! Do what you need with the button
int[] menuSearchLocation = new int[2];
menuSearch.getLocationInWindow(menuSearchLocation);
return menuSearchLocation[0] + menuSearch.getWidth() / 2;
}
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
private void circleReveal(int viewID, int posFromRight, boolean containsOverflow, final boolean isShow)
{
final View myView = findViewById(viewID);
int width=this.toolbar.getWidth();
int cx=getActionSearchMenuLocation();
int cy=this.toolbar.getHeight()/2;
Animator anim;
if(isShow)
anim = ViewAnimationUtils.createCircularReveal(myView, cx, cy, 0,(float)width);
else
anim = ViewAnimationUtils.createCircularReveal(myView, cx, cy, (float)width, 0);
anim.setDuration((long)220);
// make the view invisible when the animation is done
anim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
if(!isShow)
{
super.onAnimationEnd(animation);
myView.setVisibility(View.INVISIBLE);
}
}
});
// make the view visible and start the animation
if(isShow)
myView.setVisibility(View.VISIBLE);
// start the animation
anim.start();
}
I also face this problem after an hour of debugging and research i figure out the the issue.This happens because search toolbar initially is Gone State.Search Toolbar view did not inflate when animation start method trigger try changing View.Gone to View.Invisible in XMl layout Now it work Perfectly.In the end Kudos to developer who make this search bar tutorial for beginner (Y)
I notice that when the search icon is being clicked for the first time, animation effect is not visible. The animation effect will only be visible for 2nd time.
I look at the source code. However, I have no idea why there's such strange behavior.
Thank you
The text was updated successfully, but these errors were encountered: