private void setupStandardButtonOutline() { Outline roundRectOutline = new Outline(); roundRectOutline.setRoundRect( 0, 0, standardButton.getLayoutParams().width, standardButton.getLayoutParams().height, 20); standardButton.setOutline(roundRectOutline); standardButton.setClipToOutline(true); }
/* Android's elevation implementation requires this to be implemented to know where to draw the shadow. */ @Override public void getOutline(Outline outline) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { super.getOutline(outline); return; } if ((!CSSConstants.isUndefined(mBorderRadius) && mBorderRadius > 0) || mBorderCornerRadii != null) { updatePath(); outline.setConvexPath(mPathForBorderRadiusOutline); } else { outline.setRect(getBounds()); } }
@Override public void getOutline(View view, Outline outline) { outline.setOval( view.getPaddingLeft(), view.getPaddingTop(), view.getWidth() - view.getPaddingRight(), view.getHeight() - view.getPaddingBottom()); }
@Override public void getOutline(@NonNull Outline outline) { final Rect bounds = getBounds(); if (bounds.isEmpty()) return; if (mNinePatchState != null) { NinePatch.InsetStruct insets = mNinePatchState.getBitmap().getNinePatchInsets(); if (insets != null) { final Rect outlineInsets = insets.outlineRect; outline.setRoundRect( bounds.left + outlineInsets.left, bounds.top + outlineInsets.top, bounds.right - outlineInsets.right, bounds.bottom - outlineInsets.bottom, insets.outlineRadius); outline.setAlpha(insets.outlineAlpha * (getAlpha() / 255.0f)); return; } } super.getOutline(outline); }
@Override public void getOutline(View view, Outline outline) { int outlineLeft = view.getPaddingLeft(); int outlineTop = view.getPaddingTop(); // Apply padding to shadow. outline.setRoundRect( outlineLeft, outlineTop, view.getWidth() - outlineLeft - view.getPaddingRight(), view.getHeight() - outlineTop - view.getPaddingBottom(), sRoundedRectCornerRadius); }
@TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override public void getOutline(@NonNull Outline outline) { outline.setRoundRect(getBounds(), cornerRadius); }
/** * Called to get the drawable to populate the Outline that defines its drawing area. * * <p>This method is called by the default {@link android.view.ViewOutlineProvider} to define the * outline of the View. * * <p>The default behavior defines the outline to be the bounding rectangle of 0 alpha. Subclasses * that wish to convey a different shape or alpha value must override this method. * * @see android.view.View#setOutlineProvider(android.view.ViewOutlineProvider) */ public void getOutline(@NonNull Outline outline) { outline.setRect(getBounds()); outline.setAlpha(0); }
@Override public void setAlpha(float alpha) { outline.setAlpha(alpha); }
@Override public void setEmpty() { outline.setEmpty(); }
@Override public float getAlpha() { return outline.getAlpha(); }
@Override public void setOval(Rect rect) { outline.setOval(rect); }
@Override public void setRect(Rect rect) { outline.setRect(rect); }
@Override public void setConvexPath(Path convexPath) { outline.setConvexPath(convexPath); }
@Override public void setOval(int left, int top, int right, int bottom) { outline.setOval(left, top, right, bottom); }
@Override public boolean canClip() { return outline.canClip(); }
@Override public void getOutline(View view, Outline outline) { outline.setOval(0, 0, width, height); }
@Override public void set(Outline src) { outline.set(src); }
@Override public void setRoundRect(int left, int top, int right, int bottom, float radius) { outline.setRoundRect(left, top, right, bottom, radius); }
@Override public void setRoundRect(Rect rect, float radius) { outline.setRoundRect(rect, radius); }
@Override public void getOutline(@NonNull Outline outline) { outline.setRoundRect(getBounds(), cornerRadius); }
@Override public boolean isEmpty() { return outline.isEmpty(); }
@Override public void getOutline(Outline outline) { outline.setRoundRect(mBoundsI, mRadius); }
@Override public final void getOutline(View view, Outline outline) { outline.setOval(0, 0, mSize, mSize); }