Search in sources :

Example 36 with Outline

use of android.graphics.Outline in project android_frameworks_base by crdroidandroid.

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();
        if (outlineProvider != null) {
            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 37 with Outline

use of android.graphics.Outline in project Shuttle by timusus.

the class PlayPauseView method onSizeChanged.

@Override
protected void onSizeChanged(final int w, final int h, int oldw, int oldh) {
    super.onSizeChanged(w, h, oldw, oldh);
    drawable.setBounds(0, 0, w, h);
    width = w;
    height = h;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        setOutlineProvider(new ViewOutlineProvider() {

            @TargetApi(Build.VERSION_CODES.LOLLIPOP)
            @Override
            public void getOutline(View view, Outline outline) {
                outline.setOval(0, 0, view.getWidth(), view.getHeight());
            }
        });
        setClipToOutline(true);
    }
}
Also used : Outline(android.graphics.Outline) ViewOutlineProvider(android.view.ViewOutlineProvider) TargetApi(android.annotation.TargetApi) View(android.view.View)

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