List of usage examples for android.view ViewAnimationUtils createCircularReveal
public static Animator createCircularReveal(View view, int centerX, int centerY, float startRadius, float endRadius)
From source file:org.cyanogenmod.designertools.ui.CreditsActivity.java
private void circularRevealActivity(View v) { int cx = v.getWidth() / 2; int cy = v.getHeight() / 2; float finalRadius = Math.max(v.getWidth(), v.getHeight()); // create the animator for this view (the start radius is zero) Animator circularReveal = ViewAnimationUtils.createCircularReveal(v, cx, cy, 0, finalRadius); circularReveal.setDuration(getResources().getInteger(R.integer.credits_circular_reveal_duration)); // make the view visible and start the animation v.setVisibility(View.VISIBLE); circularReveal.setInterpolator(new AccelerateDecelerateInterpolator()); circularReveal.addListener(new Animator.AnimatorListener() { @Override/*from w ww . ja v a 2s .com*/ public void onAnimationStart(Animator animator) { } @Override public void onAnimationEnd(Animator animator) { animateContent(); } @Override public void onAnimationCancel(Animator animator) { } @Override public void onAnimationRepeat(Animator animator) { } }); circularReveal.start(); }
From source file:com.example.toolbardemo.Fragment.CircularRevealFragment.java
/** * {@inheritDoc}//from ww w . ja va 2 s . c om * @see android.support.v4.app.Fragment#onActivityCreated(android.os.Bundle) */ @Override public void onActivityCreated(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onActivityCreated(savedInstanceState); tv1 = (TextView) getActivity().findViewById(R.id.textView1); tv2 = (TextView) getActivity().findViewById(R.id.textView2); tv3 = (TextView) getActivity().findViewById(R.id.textView3); tv4 = (TextView) getActivity().findViewById(R.id.textView4); tv1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Animator animator = ViewAnimationUtils.createCircularReveal(tv1, tv1.getWidth() / 2, tv1.getHeight() / 2, tv1.getWidth(), 0); animator.setInterpolator(new AccelerateDecelerateInterpolator()); animator.setDuration(1000); animator.start(); } }); tv2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Animator animator = ViewAnimationUtils.createCircularReveal(tv2, 0, 0, 0, (float) Math.hypot(tv2.getWidth(), tv2.getHeight())); animator.setInterpolator(new AccelerateInterpolator()); animator.setDuration(1000); animator.start(); } }); tv3.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Animator animator = ViewAnimationUtils.createCircularReveal(tv3, tv3.getWidth() / 2, tv3.getHeight() / 2, 0, tv3.getWidth()); animator.setInterpolator(new AccelerateInterpolator()); animator.setDuration(1000); animator.start(); } }); tv4.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Animator animator = ViewAnimationUtils.createCircularReveal(tv4, 0, 0, (float) Math.hypot(tv4.getWidth(), tv4.getHeight()), 0); animator.setInterpolator(new AccelerateInterpolator()); animator.setDuration(1000); animator.start(); } }); }
From source file:com.andryr.guitartuner.Utils.java
public static void reveal(View view) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { // get the center for the clipping circle int cx = view.getWidth() / 2; int cy = view.getHeight() / 2; // get the final radius for the clipping circle float finalRadius = (float) Math.hypot(cx, cy); // create the animator for this view (the start radius is zero) Animator anim = ViewAnimationUtils.createCircularReveal(view, cx, cy, 0, finalRadius); // make the view visible and start the animation view.setVisibility(View.VISIBLE); anim.start();// w ww . j a v a2 s. co m } else { view.setVisibility(View.VISIBLE); view.animate().alpha(1f).start(); } }
From source file:com.example.android.revealeffectbasic.RevealEffectBasicFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View rootView = inflater.inflate(R.layout.reveal_effect_basic, container, false); View button = rootView.findViewById(R.id.button); // Set a listener to reveal the view when clicked. button.setOnClickListener(new View.OnClickListener() { @Override//from w w w. j a v a 2 s. c om public void onClick(View view) { View shape = rootView.findViewById(R.id.circle); // Create a reveal {@link Animator} that starts clipping the view from // the top left corner until the whole view is covered. Animator animator = ViewAnimationUtils.createCircularReveal(shape, 0, 0, 0, (float) Math.hypot(shape.getWidth(), shape.getHeight())); // Set a natural ease-in/ease-out interpolator. animator.setInterpolator(new AccelerateDecelerateInterpolator()); // Finally start the animation animator.start(); Log.d(TAG, "Starting Reveal animation"); } }); return rootView; }
From source file:im.ene.ribbon.AnimUtil.java
static void animate(BottomNavigationView parent, View view, final View backgroundOverlay, final ColorDrawable backgroundDrawable, final int newColor, long duration) { int centerX = (int) (ViewCompat.getX(view) + (view.getWidth() / 2)); int centerY = parent.getPaddingTop() + view.getHeight() / 2; backgroundOverlay.clearAnimation();/*w w w .j ava 2 s. c o m*/ final Object animator; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Animator currentAnimator = (Animator) backgroundOverlay.getTag(R.id.ribbon_background_overlay_animator); if (currentAnimator != null) { //currentAnimator.end(); currentAnimator.cancel(); } final float startRadius = 1; final float finalRadius = centerX > parent.getWidth() / 2 ? centerX : parent.getWidth() - centerX; animator = ViewAnimationUtils.createCircularReveal(backgroundOverlay, centerX, centerY, startRadius, finalRadius); backgroundOverlay.setTag(R.id.ribbon_background_overlay_animator, animator); } else { ViewCompat.setAlpha(backgroundOverlay, 0); animator = ViewCompat.animate(backgroundOverlay).alpha(1); } backgroundOverlay.setBackgroundColor(newColor); backgroundOverlay.setVisibility(View.VISIBLE); if (animator instanceof ViewPropertyAnimatorCompat) { ((ViewPropertyAnimatorCompat) animator).setListener(new ViewPropertyAnimatorListener() { boolean cancelled; @Override public void onAnimationStart(final View view) { } @Override public void onAnimationEnd(final View view) { if (!cancelled) { backgroundDrawable.setColor(newColor); backgroundOverlay.setVisibility(View.INVISIBLE); ViewCompat.setAlpha(backgroundOverlay, 1); } } @Override public void onAnimationCancel(final View view) { cancelled = true; } }).setDuration(duration).start(); } else { Animator animator1 = (Animator) animator; animator1.setDuration(duration); animator1.setInterpolator(new DecelerateInterpolator()); animator1.addListener(new Animator.AnimatorListener() { boolean cancelled; @Override public void onAnimationStart(final Animator animation) { } @Override public void onAnimationEnd(final Animator animation) { if (!cancelled) { backgroundDrawable.setColor(newColor); backgroundOverlay.setVisibility(View.INVISIBLE); ViewCompat.setAlpha(backgroundOverlay, 1); } } @Override public void onAnimationCancel(final Animator animation) { cancelled = true; } @Override public void onAnimationRepeat(final Animator animation) { } }); animator1.start(); } }
From source file:tech.salroid.filmy.fragment.FullReadFragment.java
@Nullable @Override/* w w w . j av a 2 s . c o m*/ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.read_full_layout, container, false); ButterKnife.bind(this, view); crossButton.setOnClickListener(this); // To run the animation as soon as the view is layout in the view hierarchy we add this // listener and remove it // as soon as it runs to prevent multiple animations if the view changes bounds view.addOnLayoutChangeListener(new View.OnLayoutChangeListener() { @Override public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { v.removeOnLayoutChangeListener(this); int cx = getArguments().getInt("cx"); int cy = getArguments().getInt("cy"); // get the hypothenuse so the radius is from one corner to the other int radius = (int) Math.hypot(right, bottom); Animator reveal; if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) { reveal = ViewAnimationUtils.createCircularReveal(v, cx, cy, 0, radius); reveal.setInterpolator(new DecelerateInterpolator(2f)); reveal.setDuration(1000); reveal.start(); } } }); return view; }
From source file:com.mvcoding.financius.feature.RevealTransition.java
private Animator createAnimator(View view, float startRadius, float endRadius) { int centerX = view.getWidth() / 2; int centerY = view.getHeight() / 2; Animator reveal = ViewAnimationUtils.createCircularReveal(view, centerX, centerY, startRadius, endRadius); return new NoPauseAnimator(reveal); }
From source file:com.andryr.guitartuner.Utils.java
public static void hide(final View view) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { // get the center for the clipping circle int cx = view.getWidth() / 2; int cy = view.getHeight() / 2; // get the initial radius for the clipping circle float initialRadius = (float) Math.hypot(cx, cy); // create the animation (the final radius is zero) Animator anim = ViewAnimationUtils.createCircularReveal(view, cx, cy, initialRadius, 0); // make the view invisible when the animation is done anim.addListener(new AnimatorListenerAdapter() { @Override//from w ww .j a v a 2s.c o m public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); view.setVisibility(View.INVISIBLE); } }); // start the animation anim.start(); } else { view.animate().alpha(0f).setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); view.setVisibility(View.INVISIBLE); } }).start(); } }
From source file:com.chromium.fontinstaller.util.ViewUtils.java
public static void reveal(Activity activity, View view, View sourceView, int colorRes) { if (activity == null || view == null || sourceView == null) return;/*from w ww . j a v a 2s . c om*/ if (isLollipop()) { final ViewGroupOverlay groupOverlay = (ViewGroupOverlay) activity.getWindow().getDecorView() .getOverlay(); final Rect displayRect = new Rect(); view.getGlobalVisibleRect(displayRect); // Make reveal cover the display and status bar. final View revealView = new View(activity); revealView.setTop(displayRect.top); revealView.setBottom(displayRect.bottom); revealView.setLeft(displayRect.left); revealView.setRight(displayRect.right); revealView.setBackgroundColor(ContextCompat.getColor(activity, colorRes)); groupOverlay.add(revealView); final int[] clearLocation = new int[2]; sourceView.getLocationInWindow(clearLocation); clearLocation[0] += sourceView.getWidth() / 2; clearLocation[1] += sourceView.getHeight() / 2; final int revealCenterX = clearLocation[0] - revealView.getLeft(); final int revealCenterY = clearLocation[1] - revealView.getTop(); final double x1_2 = Math.pow(revealView.getLeft() - revealCenterX, 2); final double x2_2 = Math.pow(revealView.getRight() - revealCenterX, 2); final double y_2 = Math.pow(revealView.getTop() - revealCenterY, 2); final float revealRadius = (float) Math.max(Math.sqrt(x1_2 + y_2), Math.sqrt(x2_2 + y_2)); try { final Animator revealAnimator = ViewAnimationUtils.createCircularReveal(revealView, revealCenterX, revealCenterY, 0.0f, revealRadius); revealAnimator .setDuration(activity.getResources().getInteger(android.R.integer.config_mediumAnimTime)); final Animator alphaAnimator = ObjectAnimator.ofFloat(revealView, View.ALPHA, 0.0f); alphaAnimator .setDuration(activity.getResources().getInteger(android.R.integer.config_shortAnimTime)); alphaAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); view.startAnimation(AnimationUtils.loadAnimation(activity, R.anim.abc_fade_in)); view.setVisibility(View.VISIBLE); } }); final AnimatorSet animatorSet = new AnimatorSet(); animatorSet.play(revealAnimator).before(alphaAnimator); animatorSet.setInterpolator(new AccelerateDecelerateInterpolator()); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animator) { groupOverlay.remove(revealView); } }); animatorSet.start(); } catch (IllegalStateException e) { Timber.i("View is detached - not animating"); } } else { view.setVisibility(View.VISIBLE); } }
From source file:io.vit.vitio.StartScreens.DetailFragment.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP) void circularRevealSchoolImage() { // previously invisible view displayImage.setVisibility(View.INVISIBLE); final View myView = displayImage; // get the center for the clipping circle int cx = myView.getMeasuredWidth() / 2; int cy = myView.getMeasuredHeight() / 2; // get the final radius for the clipping circle int finalRadius = Math.max(myView.getWidth(), myView.getHeight()) / 2; // create the animator for this view (the start radius is zero) Animator anim = ViewAnimationUtils.createCircularReveal(myView, cx, cy, 0, finalRadius); // make the view visible and start the animation myView.setVisibility(View.VISIBLE); anim.start();//w w w .j a va 2 s .c o m }