I currently have a circular reveal animation that starts from the very right of the toolbar. I want the initial circle center to start from the "search" icon which had me struggle to find an answer. I tried altering the cx
and xy
values and am unsuccessful. Any help is appreciated.
final Toolbar search_bar = (Toolbar) findViewById(R.id.search_toolbar);
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
int cx = search_bar.getWidth();
int cy = search_bar.getHeight()/2;
float finalRadius = (float) Math.hypot(cx, cy);
Animator anim =
ViewAnimationUtils.createCircularReveal(search_bar, cx, cy, 0, finalRadius);
search_bar.setVisibility(View.VISIBLE);
anim.start();
}
try this :
Change the view to the view that you want to do reveal on top of it ( usually root view ), and startView to your "search" icon view, and onAnimationEnd do whatever you want after the reveal is finished.
UPDATE
If the reveal is not on top of your views, there is a little trick to fix it by adding this view to the bottom of your layout
make sure that the view "view" set to the id of that layout
Basically what I did is adding a LinearLayout and set its width and height to match match_parent, so this view is on top of everything and this view is where the reveal will be on top of, and to make sure that view doesn't effect your layout I set visibility to invisible, and set it to visible right at the beginning of the reveal:
view.setVisibility(View.VISIBLE);
I hope it helps.