Search in sources :

Example 31 with Outline

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

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 32 with Outline

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

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 33 with Outline

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

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 34 with Outline

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

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 35 with Outline

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

the class TaskView method onFinishInflate.

@Override
protected void onFinishInflate() {
    // Bind the views
    mHeaderView = (TaskViewHeader) findViewById(R.id.task_view_bar);
    mThumbnailView = (TaskViewThumbnail) findViewById(R.id.task_view_thumbnail);
    mThumbnailView.updateClipToTaskBar(mHeaderView);
    mActionButtonView = findViewById(R.id.lock_to_app_fab);
    mActionButtonView.setOutlineProvider(new ViewOutlineProvider() {

        @Override
        public void getOutline(View view, Outline outline) {
            // Set the outline to match the FAB background
            outline.setOval(0, 0, mActionButtonView.getWidth(), mActionButtonView.getHeight());
            outline.setAlpha(0.35f);
        }
    });
    mActionButtonView.setOnClickListener(this);
    mActionButtonTranslationZ = mActionButtonView.getTranslationZ();
}
Also used : Outline(android.graphics.Outline) ViewOutlineProvider(android.view.ViewOutlineProvider) View(android.view.View) TextView(android.widget.TextView)

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