Java Code Examples for android.graphics.Outline#setAlpha()
The following examples show how to use
android.graphics.Outline#setAlpha() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Magnifier.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
private RenderNode createRenderNodeForBitmap(final String name, final float elevation, final float cornerRadius) { final RenderNode bitmapRenderNode = RenderNode.create(name, null); // Define the position of the bitmap in the parent render node. The surface regions // outside the bitmap are used to draw elevation. bitmapRenderNode.setLeftTopRightBottom(mOffsetX, mOffsetY, mOffsetX + mContentWidth, mOffsetY + mContentHeight); bitmapRenderNode.setElevation(elevation); final Outline outline = new Outline(); outline.setRoundRect(0, 0, mContentWidth, mContentHeight, cornerRadius); outline.setAlpha(1.0f); bitmapRenderNode.setOutline(outline); bitmapRenderNode.setClipToOutline(true); // Create a dummy draw, which will be replaced later with real drawing. final DisplayListCanvas canvas = bitmapRenderNode.start(mContentWidth, mContentHeight); try { canvas.drawColor(0xFF00FF00); } finally { bitmapRenderNode.end(canvas); } return bitmapRenderNode; }
Example 2
Source File: ChipDrawable.java From material-components-android with Apache License 2.0 | 6 votes |
@Override @TargetApi(VERSION_CODES.LOLLIPOP) public void getOutline(@NonNull Outline outline) { if (isShapeThemingEnabled) { super.getOutline(outline); return; } Rect bounds = getBounds(); if (!bounds.isEmpty()) { outline.setRoundRect(bounds, chipCornerRadius); } else { outline.setRoundRect(0, 0, getIntrinsicWidth(), getIntrinsicHeight(), chipCornerRadius); } outline.setAlpha(getAlpha() / 255f); }
Example 3
Source File: LineDrawable.java From ProjectX with Apache License 2.0 | 6 votes |
@TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override public void getOutline(Outline outline) { final int[] state = getState(); final int backgroundColor = DrawableHelper.getColor(mBackgroundColor, state, mAlpha); final int backgroundAlpha = Color.alpha(backgroundColor); if (backgroundAlpha != 0) { outline.setRect(getBounds()); outline.setAlpha(backgroundAlpha / 255f); return; } final int lineColor = DrawableHelper.getColor(mLineColor, state, mAlpha); final int lineAlpha = Color.alpha(lineColor); outline.setRect(Math.round(mLine.left - 0.5f), Math.round(mLine.top - 0.5f), Math.round(mLine.right + 0.5f), Math.round(mLine.bottom + 0.5f)); outline.setAlpha(lineAlpha / 255f); }
Example 4
Source File: ViewOutlineProvider.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
@Override public void getOutline(View view, Outline outline) { Drawable background = view.getBackground(); if (background != null) { background.getOutline(outline); } else { outline.setRect(0, 0, view.getWidth(), view.getHeight()); outline.setAlpha(0.0f); } }
Example 5
Source File: NotificationHeaderView.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
@Override public void getOutline(View view, Outline outline) { if (mBackground != null) { outline.setRect(0, 0, getWidth(), getHeight()); outline.setAlpha(1f); } }
Example 6
Source File: CornerDrawable.java From ProjectX with Apache License 2.0 | 5 votes |
@TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override public void getOutline(Outline outline) { if (mPath.isEmpty() || !mPath.isConvex()) { super.getOutline(outline); return; } final int[] state = getState(); final int fillColor = DrawableHelper.getColor(mFillColor, state, mAlpha); final int strokeColor = DrawableHelper.getColor(mStrokeColor, state, mAlpha); final int alpha = Math.max(Color.alpha(fillColor), Color.alpha(strokeColor)); outline.setConvexPath(mPath); outline.setAlpha(alpha / 255f); }
Example 7
Source File: ClipDrawable.java From ProjectX with Apache License 2.0 | 5 votes |
@TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override public void getOutline(@SuppressWarnings("NullableProblems") Outline outline) { if (mProvider == null || mOutlinePath.isEmpty() || !mOutlinePath.isConvex()) { super.getOutline(outline); return; } outline.setConvexPath(mOutlinePath); outline.setAlpha(1); }
Example 8
Source File: RoundedRectHelperApi21.java From adt-leanback-support with Apache License 2.0 | 5 votes |
@Override public void getOutline(View view, Outline outline) { if (sCornerRadius == 0) { sCornerRadius = view.getResources().getDimensionPixelSize( R.dimen.lb_rounded_rect_corner_radius); } outline.setRoundRect(0, 0, view.getWidth(), view.getHeight(), sCornerRadius); outline.setAlpha(1f); }
Example 9
Source File: TouchEffectDrawable.java From Genius-Android with Apache License 2.0 | 5 votes |
@TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override public void getOutline(Outline outline) { if (mState.mEffect != null) { mState.mEffect.getOutline(outline); outline.setAlpha(getAlpha() / 255.0f); } }
Example 10
Source File: TapTargetView.java From styT with Apache License 2.0 | 4 votes |
protected void applyTargetOptions(Context context) { shouldTintTarget = target.tintTarget; shouldDrawShadow = target.drawShadow; cancelable = target.cancelable; // We can't clip out portions of a view outline, so if the user specified a transparent // target, we need to fallback to drawing a jittered shadow approximation if (shouldDrawShadow && Build.VERSION.SDK_INT >= 21 && !target.transparentTarget) { outlineProvider = new ViewOutlineProvider() { @TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override public void getOutline(View view, Outline outline) { if (outerCircleCenter == null) return; outline.setOval( (int) (outerCircleCenter[0] - outerCircleRadius), (int) (outerCircleCenter[1] - outerCircleRadius), (int) (outerCircleCenter[0] + outerCircleRadius), (int) (outerCircleCenter[1] + outerCircleRadius)); outline.setAlpha(outerCircleAlpha / 255.0f); if (Build.VERSION.SDK_INT >= 22) { outline.offset(0, SHADOW_DIM); } } }; setOutlineProvider(outlineProvider); setElevation(SHADOW_DIM); } setLayerType(LAYER_TYPE_HARDWARE, null); final Resources.Theme theme = context.getTheme(); isDark = UiUtil.themeIntAttr(context, "isLightTheme") == 0; final Integer outerCircleColor = target.outerCircleColorInt(context); if (outerCircleColor != null) { outerCirclePaint.setColor(outerCircleColor); } else if (theme != null) { outerCirclePaint.setColor(UiUtil.themeIntAttr(context, "colorPrimary")); } else { outerCirclePaint.setColor(Color.WHITE); } final Integer targetCircleColor = target.targetCircleColorInt(context); if (targetCircleColor != null) { targetCirclePaint.setColor(targetCircleColor); } else { targetCirclePaint.setColor(isDark ? Color.BLACK : Color.WHITE); } if (target.transparentTarget) { targetCirclePaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR)); } targetCirclePulsePaint.setColor(targetCirclePaint.getColor()); final Integer targetDimColor = target.dimColorInt(context); if (targetDimColor != null) { dimColor = UiUtil.setAlpha(targetDimColor, 0.3f); } else { dimColor = -1; } final Integer titleTextColor = target.titleTextColorInt(context); if (titleTextColor != null) { titlePaint.setColor(titleTextColor); } else { titlePaint.setColor(isDark ? Color.BLACK : Color.WHITE); } final Integer descriptionTextColor = target.descriptionTextColorInt(context); if (descriptionTextColor != null) { descriptionPaint.setColor(descriptionTextColor); } else { descriptionPaint.setColor(titlePaint.getColor()); } if (target.titleTypeface != null) { titlePaint.setTypeface(target.titleTypeface); } if (target.descriptionTypeface != null) { descriptionPaint.setTypeface(target.descriptionTypeface); } }
Example 11
Source File: TapTargetView.java From TapTargetView with Apache License 2.0 | 4 votes |
protected void applyTargetOptions(Context context) { shouldTintTarget = !target.transparentTarget && target.tintTarget; shouldDrawShadow = target.drawShadow; cancelable = target.cancelable; // We can't clip out portions of a view outline, so if the user specified a transparent // target, we need to fallback to drawing a jittered shadow approximation if (shouldDrawShadow && Build.VERSION.SDK_INT >= 21 && !target.transparentTarget) { outlineProvider = new ViewOutlineProvider() { @TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override public void getOutline(View view, Outline outline) { if (outerCircleCenter == null) return; outline.setOval( (int) (outerCircleCenter[0] - outerCircleRadius), (int) (outerCircleCenter[1] - outerCircleRadius), (int) (outerCircleCenter[0] + outerCircleRadius), (int) (outerCircleCenter[1] + outerCircleRadius)); outline.setAlpha(outerCircleAlpha / 255.0f); if (Build.VERSION.SDK_INT >= 22) { outline.offset(0, SHADOW_DIM); } } }; setOutlineProvider(outlineProvider); setElevation(SHADOW_DIM); } if (shouldDrawShadow && outlineProvider == null && Build.VERSION.SDK_INT < 18) { setLayerType(LAYER_TYPE_SOFTWARE, null); } else { setLayerType(LAYER_TYPE_HARDWARE, null); } final Resources.Theme theme = context.getTheme(); isDark = UiUtil.themeIntAttr(context, "isLightTheme") == 0; final Integer outerCircleColor = target.outerCircleColorInt(context); if (outerCircleColor != null) { outerCirclePaint.setColor(outerCircleColor); } else if (theme != null) { outerCirclePaint.setColor(UiUtil.themeIntAttr(context, "colorPrimary")); } else { outerCirclePaint.setColor(Color.WHITE); } final Integer targetCircleColor = target.targetCircleColorInt(context); if (targetCircleColor != null) { targetCirclePaint.setColor(targetCircleColor); } else { targetCirclePaint.setColor(isDark ? Color.BLACK : Color.WHITE); } if (target.transparentTarget) { targetCirclePaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR)); } targetCirclePulsePaint.setColor(targetCirclePaint.getColor()); final Integer targetDimColor = target.dimColorInt(context); if (targetDimColor != null) { dimColor = UiUtil.setAlpha(targetDimColor, 0.3f); } else { dimColor = -1; } final Integer titleTextColor = target.titleTextColorInt(context); if (titleTextColor != null) { titlePaint.setColor(titleTextColor); } else { titlePaint.setColor(isDark ? Color.BLACK : Color.WHITE); } final Integer descriptionTextColor = target.descriptionTextColorInt(context); if (descriptionTextColor != null) { descriptionPaint.setColor(descriptionTextColor); } else { descriptionPaint.setColor(titlePaint.getColor()); } if (target.titleTypeface != null) { titlePaint.setTypeface(target.titleTypeface); } if (target.descriptionTypeface != null) { descriptionPaint.setTypeface(target.descriptionTypeface); } }
Example 12
Source File: RadialGradientRippleAnimationDrawable.java From ProjectX with Apache License 2.0 | 4 votes |
@TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override public void getOutline(Outline outline) { outline.setRect(getBounds()); outline.setAlpha(1); }
Example 13
Source File: ShadowHelperApi21.java From adt-leanback-support with Apache License 2.0 | 4 votes |
@Override public void getOutline(View view, Outline outline) { outline.setRect(0, 0, view.getWidth(), view.getHeight()); outline.setAlpha(1.0f); }