Search in sources :

Example 31 with ViewOutlineProvider

use of android.view.ViewOutlineProvider in project RxTools by vondear.

the class RxPopupViewManager method setTipViewElevation.

private void setTipViewElevation(TextView tipView, RxPopupView rxPopupView) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        if (rxPopupView.getElevation() > 0) {
            ViewOutlineProvider viewOutlineProvider = new ViewOutlineProvider() {

                @SuppressLint("NewApi")
                @Override
                public void getOutline(View view, Outline outline) {
                    outline.setEmpty();
                }
            };
            tipView.setOutlineProvider(viewOutlineProvider);
            tipView.setElevation(rxPopupView.getElevation());
        }
    }
}
Also used : Outline(android.graphics.Outline) ViewOutlineProvider(android.view.ViewOutlineProvider) TextView(android.widget.TextView) View(android.view.View)

Example 32 with ViewOutlineProvider

use of android.view.ViewOutlineProvider in project android_frameworks_base by ResurrectionRemix.

the class TaskCardView method setAsScreenShotView.

private void setAsScreenShotView(Bitmap screenshot, ImageView screenshotView) {
    LayoutParams lp = (LayoutParams) screenshotView.getLayoutParams();
    lp.width = LayoutParams.MATCH_PARENT;
    lp.height = LayoutParams.MATCH_PARENT;
    screenshotView.setLayoutParams(lp);
    screenshotView.setClipToOutline(true);
    screenshotView.setOutlineProvider(new ViewOutlineProvider() {

        @Override
        public void getOutline(View view, Outline outline) {
            outline.setRoundRect(0, 0, view.getWidth(), view.getHeight(), mCornerRadius);
        }
    });
    screenshotView.setImageBitmap(screenshot);
}
Also used : Outline(android.graphics.Outline) ViewOutlineProvider(android.view.ViewOutlineProvider) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView)

Example 33 with ViewOutlineProvider

use of android.view.ViewOutlineProvider in project KL2 by jweihao.

the class ClippingActivity method onViewClicked.

@OnClick({ R.id.tv_rect, R.id.tv_circle })
public void onViewClicked(View view) {
    switch(view.getId()) {
        case R.id.tv_rect:
            // 获取Outline
            ViewOutlineProvider rect = new ViewOutlineProvider() {

                @Override
                public void getOutline(View view, Outline outline) {
                    // 修改outline为特定形状
                    outline.setRoundRect(0, 0, view.getWidth(), view.getHeight(), 30);
                }
            };
            // 重新设置形状
            mTvRect.setOutlineProvider(rect);
            break;
        case R.id.tv_circle:
            // 获取Outline
            ViewOutlineProvider circle = new ViewOutlineProvider() {

                @Override
                public void getOutline(View view, Outline outline) {
                    // 修改outline为特定形状
                    outline.setOval(0, 0, view.getWidth(), view.getHeight());
                }
            };
            // 重新设置形状
            mTvCircle.setOutlineProvider(circle);
            break;
        default:
            break;
    }
}
Also used : Outline(android.graphics.Outline) ViewOutlineProvider(android.view.ViewOutlineProvider) TextView(android.widget.TextView) View(android.view.View) BindView(butterknife.BindView) OnClick(butterknife.OnClick)

Example 34 with ViewOutlineProvider

use of android.view.ViewOutlineProvider in project android_packages_apps_Dialer by MoKee.

the class CircularRevealFragment method startOutgoingAnimation.

public void startOutgoingAnimation(MaterialPalette palette) {
    final Activity activity = getActivity();
    if (activity == null) {
        Log.w(this, "Asked to do outgoing call animation when not attached");
        return;
    }
    final View view = activity.getWindow().getDecorView();
    // The circle starts from an initial size of 0 so clip it such that it is invisible.
    // Otherwise the first frame is drawn with a fully opaque screen which causes jank. When
    // the animation later starts, this clip will be clobbered by the circular reveal clip.
    // See ViewAnimationUtils.createCircularReveal.
    view.setOutlineProvider(new ViewOutlineProvider() {

        @Override
        public void getOutline(View view, Outline outline) {
            // Using (0, 0, 0, 0) will not work since the outline will simply be treated as
            // an empty outline.
            outline.setOval(-1, -1, 0, 0);
        }
    });
    view.setClipToOutline(true);
    if (palette != null) {
        view.findViewById(R.id.outgoing_call_animation_circle).setBackgroundColor(palette.mPrimaryColor);
        activity.getWindow().setStatusBarColor(palette.mSecondaryColor);
        activity.getWindow().setNavigationBarColor(palette.mSecondaryColor);
    }
    view.getViewTreeObserver().addOnPreDrawListener(new OnPreDrawListener() {

        @Override
        public boolean onPreDraw() {
            mAnimationFinished = false;
            final ViewTreeObserver vto = view.getViewTreeObserver();
            if (vto.isAlive()) {
                vto.removeOnPreDrawListener(this);
            }
            final Animator animator = getRevealAnimator(mTouchPoint);
            if (animator != null) {
                animator.addListener(new AnimatorListenerAdapter() {

                    @Override
                    public void onAnimationEnd(Animator animation) {
                        Log.w(TAG, " CircularRevealFragment - onAnimationEnd");
                        view.setClipToOutline(false);
                        if (mListener != null && mAnimationFinished == false) {
                            mListener.onCircularRevealComplete(getFragmentManager());
                            mAnimationFinished = true;
                        }
                    }
                });
                animator.start();
                // If somehow the animator is failed to run from lower layers,
                // need to wait for certain expiration time and inform the
                // listeners with OnCircularComplete callback so that rest of
                // the things will not be blocked.
                Handler handler = new Handler();
                handler.postDelayed(new Runnable() {

                    @Override
                    public void run() {
                        Log.w(TAG, " Failed to complete animation");
                        if (mListener != null && mAnimationFinished == false) {
                            mListener.onCircularRevealComplete(getFragmentManager());
                            mAnimationFinished = true;
                        }
                    }
                }, getResources().getInteger(R.integer.reveal_animation_duration) + REVEAL_ADDITIONAL_EXPIRATION_TIME);
            }
            return false;
        }
    });
}
Also used : Animator(android.animation.Animator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) Activity(android.app.Activity) Handler(android.os.Handler) Outline(android.graphics.Outline) View(android.view.View) ViewOutlineProvider(android.view.ViewOutlineProvider) OnPreDrawListener(android.view.ViewTreeObserver.OnPreDrawListener) ViewTreeObserver(android.view.ViewTreeObserver)

Example 35 with ViewOutlineProvider

use of android.view.ViewOutlineProvider in project ChatExchange by HueToYou.

the class FloatingActionButton method createFillDrawable.

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private Drawable createFillDrawable() {
    StateListDrawable drawable = new StateListDrawable();
    drawable.addState(new int[] { -android.R.attr.state_enabled }, createCircleDrawable(mColorDisabled));
    drawable.addState(new int[] { android.R.attr.state_pressed }, createCircleDrawable(mColorPressed));
    drawable.addState(new int[] {}, createCircleDrawable(mColorNormal));
    if (Util.hasLollipop()) {
        RippleDrawable ripple = new RippleDrawable(new ColorStateList(new int[][] { {} }, new int[] { mColorRipple }), drawable, null);
        setOutlineProvider(new ViewOutlineProvider() {

            @Override
            public void getOutline(View view, Outline outline) {
                outline.setOval(0, 0, view.getWidth(), view.getHeight());
            }
        });
        setClipToOutline(true);
        mBackgroundDrawable = ripple;
        return ripple;
    }
    mBackgroundDrawable = drawable;
    return drawable;
}
Also used : ColorStateList(android.content.res.ColorStateList) Outline(android.graphics.Outline) StateListDrawable(android.graphics.drawable.StateListDrawable) ViewOutlineProvider(android.view.ViewOutlineProvider) View(android.view.View) TextView(android.widget.TextView) RippleDrawable(android.graphics.drawable.RippleDrawable) TargetApi(android.annotation.TargetApi)

Aggregations

ViewOutlineProvider (android.view.ViewOutlineProvider)56 Outline (android.graphics.Outline)55 View (android.view.View)55 TextView (android.widget.TextView)25 AnimatedView (carbon.animation.AnimatedView)17 RippleView (carbon.drawable.ripple.RippleView)17 MarginView (carbon.view.MarginView)17 MaxSizeView (carbon.view.MaxSizeView)17 RevealView (carbon.view.RevealView)16 ShadowView (carbon.view.ShadowView)16 ShapeModelView (carbon.view.ShapeModelView)16 StateAnimatorView (carbon.view.StateAnimatorView)16 StrokeView (carbon.view.StrokeView)16 TouchMarginView (carbon.view.TouchMarginView)16 VisibleView (carbon.view.VisibleView)16 TargetApi (android.annotation.TargetApi)12 ComponentView (carbon.component.ComponentView)12 InsetView (carbon.view.InsetView)12 TransformationView (carbon.view.TransformationView)12 BehaviorView (carbon.view.BehaviorView)10