当前位置: 首页>>代码示例>>Java>>正文


Java ViewGroupOverlay.add方法代码示例

本文整理汇总了Java中android.view.ViewGroupOverlay.add方法的典型用法代码示例。如果您正苦于以下问题:Java ViewGroupOverlay.add方法的具体用法?Java ViewGroupOverlay.add怎么用?Java ViewGroupOverlay.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.view.ViewGroupOverlay的用法示例。


在下文中一共展示了ViewGroupOverlay.add方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: applyDim

import android.view.ViewGroupOverlay; //导入方法依赖的package包/类
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR2)
    private void applyDim(Activity activity) {
        ViewGroup parent = (ViewGroup) activity.getWindow().getDecorView().getRootView();
        //activity跟布局
//        ViewGroup parent = (ViewGroup) parent1.getChildAt(0);
        Drawable dim = new ColorDrawable(mDimColor);
        dim.setBounds(0, 0, parent.getWidth(), parent.getHeight());
        dim.setAlpha((int) (255 * mDimValue));
        ViewGroupOverlay overlay = parent.getOverlay();
        overlay.add(dim);
    }
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:EasyPopup.java

示例2: emphasizeUserError

import android.view.ViewGroupOverlay; //导入方法依赖的package包/类
private void emphasizeUserError(ViewGroup v) {
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Context ctx = v.getContext();
        final ViewGroupOverlay overlay = v.getOverlay();

        final View revealView = new View(v.getContext());
        revealView.setBottom(v.getHeight());
        revealView.setRight(v.getWidth());
        revealView.setBackgroundColor(ContextCompat.getColor(ctx, R.color.colorErrorTrans));

        overlay.add(revealView);

        float radius = (float) Math.sqrt(Math.pow(v.getHeight(), 2) + Math.pow(v.getWidth(), 2));
        Animator revealAnimator =
                ViewAnimationUtils.createCircularReveal(revealView,
                        (revealView.getWidth() / 2), revealView.getHeight(), 0.0f, radius);
        //TODO: move this into resources
        revealAnimator.setDuration(500);

        Animator alphaAnimator = ObjectAnimator.ofFloat(revealView, View.ALPHA, 0.0f);
        alphaAnimator.setDuration(200);

        AnimatorSet animatorSet = new AnimatorSet();
        animatorSet.play(revealAnimator).before(alphaAnimator);
        animatorSet.setInterpolator(new AccelerateDecelerateInterpolator());
        animatorSet.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                overlay.remove(revealView);
            }
        });

        animatorSet.start();
    }
    else {
        Toast.makeText(v.getContext(),R.string.unsupported_url_prefix,Toast.LENGTH_SHORT).show();
    }
}
 
开发者ID:TapTrack,项目名称:TappyBLE,代码行数:39,代码来源:HexCommandAdapter.java

示例3: reveal

import android.view.ViewGroupOverlay; //导入方法依赖的package包/类
public static void reveal(Activity activity, View view, View sourceView, int colorRes) {
  if (activity == null || view == null || sourceView == null) return;
  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);
  }
}
 
开发者ID:ItsPriyesh,项目名称:Fontster,代码行数:67,代码来源:ViewUtils.java

示例4: reveal5

import android.view.ViewGroupOverlay; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void reveal5(View sourceView, int colorRes, final AnimatorListenerWrapper listener) {
    final ViewGroupOverlay groupOverlay =
            (ViewGroupOverlay) getWindow().getDecorView().getOverlay();

    final Rect displayRect = new Rect();
    mDisplayView.getGlobalVisibleRect(displayRect);

    // Make reveal cover the display and status bar.
    final View revealView = new View(this);
    revealView.setBottom(displayRect.bottom);
    revealView.setLeft(displayRect.left);
    revealView.setRight(displayRect.right);
    revealView.setBackgroundColor(getResources().getColor(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));

    final Animator revealAnimator =
            ViewAnimationUtils.createCircularReveal(revealView,
                    revealCenterX, revealCenterY, 0.0f, revealRadius);
    revealAnimator.setDuration(
            getResources().getInteger(android.R.integer.config_longAnimTime));

    final Animator alphaAnimator = ObjectAnimator.ofFloat(revealView, View.ALPHA, 0.0f);
    alphaAnimator.setDuration(
            getResources().getInteger(android.R.integer.config_mediumAnimTime));
    alphaAnimator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationStart(Animator animation) {
            listener.onAnimationStart();
        }
    });

    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);
            mCurrentAnimator = null;
        }
    });

    mCurrentAnimator = animatorSet;
    animatorSet.start();
}
 
开发者ID:Sash0k,项目名称:Thrift-box,代码行数:60,代码来源:ActivityHelper.java

示例5: reveal

import android.view.ViewGroupOverlay; //导入方法依赖的package包/类
private void reveal(View sourceView, int colorRes, Animator.AnimatorListener listener) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        listener.onAnimationEnd(null);
        return;
    }

    final ViewGroupOverlay groupOverlay =
            (ViewGroupOverlay) getWindow().getDecorView().getOverlay();

    final Rect displayRect = new Rect();
    mDisplayView.getGlobalVisibleRect(displayRect);

    // Make reveal cover the display and status bar.
    final View revealView = new View(this);
    revealView.setBottom(displayRect.bottom);
    revealView.setLeft(displayRect.left);
    revealView.setRight(displayRect.right);
    revealView.setBackgroundColor(getResources().getColor(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));

    final Animator revealAnimator =
            ViewAnimationUtils.createCircularReveal(revealView,
                    revealCenterX, revealCenterY, 0.0f, revealRadius);
    revealAnimator.setDuration(
            getResources().getInteger(android.R.integer.config_longAnimTime));
    revealAnimator.addListener(listener);

    final Animator alphaAnimator = ObjectAnimator.ofFloat(revealView, View.ALPHA, 0.0f);
    alphaAnimator.setDuration(
            getResources().getInteger(android.R.integer.config_mediumAnimTime));

    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);
            mCurrentAnimator = null;
        }
    });

    mCurrentAnimator = animatorSet;
    animatorSet.start();
}
 
开发者ID:derekbrameyer,项目名称:repmaxcalculator-android,代码行数:59,代码来源:MainActivity.java


注:本文中的android.view.ViewGroupOverlay.add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。