本文整理汇总了Java中android.view.ViewGroupOverlay类的典型用法代码示例。如果您正苦于以下问题:Java ViewGroupOverlay类的具体用法?Java ViewGroupOverlay怎么用?Java ViewGroupOverlay使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ViewGroupOverlay类属于android.view包,在下文中一共展示了ViewGroupOverlay类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createAnimator
import android.view.ViewGroupOverlay; //导入依赖的package包/类
@Override
public Animator createAnimator(final ViewGroup sceneRoot, TransitionValues startValues,
final TransitionValues endValues) {
if (startValues != null && endValues != null) {
final ViewGroupOverlay overlay = sceneRoot.getOverlay();
final View view = endValues.view;
View bottomPanel = endValues.view.findViewById(R.id.fragment_announcement_details_bottom_panel);
final TextView topPanel = (TextView) endValues.view.findViewById(R.id.fragment_announcement_details_top_panel);
// TOP PANEL
ValueAnimator text = ValueAnimator.ofFloat(14, 20);
text.addUpdateListener(valueAnimator -> topPanel.setTextSize(TypedValue.COMPLEX_UNIT_SP, (Float) valueAnimator.getAnimatedValue()));
Animator top = ObjectAnimator.ofFloat(topPanel, "alpha", 0.5f, 1f);
Animator bottom = ObjectAnimator.ofFloat(bottomPanel, "alpha", 0.5f, 1f);
AnimatorSet set = new AnimatorSet();
set.playTogether(bottom, top);
set.addListener(getOverlayListener(overlay, view));
return set;
} else {
return null;
}
}
示例2: 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);
}
示例3: clearDim
import android.view.ViewGroupOverlay; //导入依赖的package包/类
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR2)
private void clearDim(Activity activity) {
ViewGroup parent = (ViewGroup) activity.getWindow().getDecorView().getRootView();
//activity跟布局
// ViewGroup parent = (ViewGroup) parent1.getChildAt(0);
ViewGroupOverlay overlay = parent.getOverlay();
overlay.clear();
}
示例4: 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();
}
}
示例5: 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);
}
}
示例6: 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();
}
示例7: 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();
}