Search in sources :

Example 21 with Outline

use of android.graphics.Outline in project platform_frameworks_base by android.

the class ViewGroup_Delegate method drawChild.

/**
     * Overrides the original drawChild call in ViewGroup to draw the shadow.
     */
@LayoutlibDelegate
static /*package*/
boolean drawChild(ViewGroup thisVG, Canvas canvas, View child, long drawingTime) {
    if (child.getZ() > thisVG.getZ()) {
        // The background's bounds are set lazily. Make sure they are set correctly so that
        // the outline obtained is correct.
        child.setBackgroundBounds();
        ViewOutlineProvider outlineProvider = child.getOutlineProvider();
        Outline outline = child.mAttachInfo.mTmpOutline;
        outlineProvider.getOutline(child, outline);
        if (outline.mPath != null || (outline.mRect != null && !outline.mRect.isEmpty())) {
            int restoreTo = transformCanvas(thisVG, canvas, child);
            drawShadow(thisVG, canvas, child, outline);
            canvas.restoreToCount(restoreTo);
        }
    }
    return thisVG.drawChild_Original(canvas, child, drawingTime);
}
Also used : Outline(android.graphics.Outline) LayoutlibDelegate(com.android.tools.layoutlib.annotations.LayoutlibDelegate)

Example 22 with Outline

use of android.graphics.Outline in project google-io-2014 by romainguy.

the class DetailActivity method setOutlines.

private void setOutlines(int star, int info) {
    final int size = getResources().getDimensionPixelSize(R.dimen.floating_button_size);
    final ViewOutlineProvider vop = new ViewOutlineProvider() {

        @Override
        public void getOutline(View view, Outline outline) {
            outline.setOval(0, 0, size, size);
        }
    };
    findViewById(star).setOutlineProvider(vop);
    findViewById(info).setOutlineProvider(vop);
}
Also used : Outline(android.graphics.Outline) ViewOutlineProvider(android.view.ViewOutlineProvider) ImageView(android.widget.ImageView) View(android.view.View) AnimatedPathView(com.example.android.io2014.ui.AnimatedPathView) TextView(android.widget.TextView)

Example 23 with Outline

use of android.graphics.Outline in project platform_frameworks_base by android.

the class View method rebuildOutline.

/**
     * Internal version of {@link #invalidateOutline()} which invalidates the
     * outline without invalidating the view itself. This is intended to be called from
     * within methods in the View class itself which are the result of the view being
     * invalidated already. For example, when we are drawing the background of a View,
     * we invalidate the outline in case it changed in the meantime, but we do not
     * need to invalidate the view because we're already drawing the background as part
     * of drawing the view in response to an earlier invalidation of the view.
     */
private void rebuildOutline() {
    // Unattached views ignore this signal, and outline is recomputed in onAttachedToWindow()
    if (mAttachInfo == null)
        return;
    if (mOutlineProvider == null) {
        // no provider, remove outline
        mRenderNode.setOutline(null);
    } else {
        final Outline outline = mAttachInfo.mTmpOutline;
        outline.setEmpty();
        outline.setAlpha(1.0f);
        mOutlineProvider.getOutline(this, outline);
        mRenderNode.setOutline(outline);
    }
}
Also used : Outline(android.graphics.Outline)

Example 24 with Outline

use of android.graphics.Outline in project FloatingActionButton by Clans.

the class Label method createFillDrawable.

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private Drawable createFillDrawable() {
    StateListDrawable drawable = new StateListDrawable();
    drawable.addState(new int[] { android.R.attr.state_pressed }, createRectDrawable(mColorPressed));
    drawable.addState(new int[] {}, createRectDrawable(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)

Example 25 with Outline

use of android.graphics.Outline in project FloatingActionButton by Clans.

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

Outline (android.graphics.Outline)37 View (android.view.View)26 ViewOutlineProvider (android.view.ViewOutlineProvider)26 TextView (android.widget.TextView)16 TargetApi (android.annotation.TargetApi)8 ImageView (android.widget.ImageView)7 LayoutlibDelegate (com.android.tools.layoutlib.annotations.LayoutlibDelegate)5 ColorStateList (android.content.res.ColorStateList)3 ColorDrawable (android.graphics.drawable.ColorDrawable)3 RippleDrawable (android.graphics.drawable.RippleDrawable)3 Animator (android.animation.Animator)2 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)2 AnimatorSet (android.animation.AnimatorSet)2 ObjectAnimator (android.animation.ObjectAnimator)2 Rect (android.graphics.Rect)2 Drawable (android.graphics.drawable.Drawable)2 StateListDrawable (android.graphics.drawable.StateListDrawable)2 ViewGroup (android.view.ViewGroup)2 Interpolator (android.view.animation.Interpolator)2 AdapterView (android.widget.AdapterView)2