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);
}
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);
}
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);
}
}
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;
}
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;
}
Aggregations