コード例 #1
0
  private void revealFrom(float x, float y, Activity a, SearchBox s) {
    FrameLayout layout =
        (FrameLayout) a.getWindow().getDecorView().findViewById(android.R.id.content);
    RelativeLayout root = (RelativeLayout) s.findViewById(R.id.search_root);
    Resources r = getResources();
    float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 96, r.getDisplayMetrics());

    int finalRadius = (int) Math.max(layout.getWidth(), px);

    SupportAnimator animator =
        ViewAnimationUtils.createCircularReveal(root, (int) x, (int) y, 0, finalRadius);
    animator.setInterpolator(new AccelerateDecelerateInterpolator());
    animator.setDuration(500);
    animator.addListener(
        new SupportAnimator.AnimatorListener() {

          @Override
          public void onAnimationCancel() {}

          @Override
          public void onAnimationEnd() {
            toggleSearch();
          }

          @Override
          public void onAnimationRepeat() {}

          @Override
          public void onAnimationStart() {}
        });
    animator.start();
  }
コード例 #2
0
  /**
   * * Hide the searchbox using the circle animation. Can be called regardless of result list length
   *
   * @param activity Activity
   */
  public void hideCircularly(int x, int y, Activity activity) {
    final FrameLayout layout =
        (FrameLayout) activity.getWindow().getDecorView().findViewById(android.R.id.content);
    RelativeLayout root = (RelativeLayout) findViewById(R.id.search_root);
    Resources r = getResources();
    float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 96, r.getDisplayMetrics());
    int finalRadius = (int) Math.max(layout.getWidth() * 1.5, px);

    SupportAnimator animator = ViewAnimationUtils.createCircularReveal(root, x, y, 0, finalRadius);
    animator.setInterpolator(new ReverseInterpolator());
    animator.setDuration(500);
    animator.start();
    animator.addListener(
        new SupportAnimator.AnimatorListener() {

          @Override
          public void onAnimationStart() {}

          @Override
          public void onAnimationEnd() {
            setVisibility(View.GONE);
          }

          @Override
          public void onAnimationCancel() {}

          @Override
          public void onAnimationRepeat() {}
        });
  }