Java Code Examples for android.graphics.Outline#setRoundRect()

The following examples show how to use android.graphics.Outline#setRoundRect() . 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 vote down vote up
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: CardFrameLayout.java    From google-io-2014 with Apache License 2.0 6 votes vote down vote up
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
    super.onSizeChanged(w, h, oldw, oldh);

    final float radius = getResources().getDimensionPixelSize(R.dimen.card_corner_radius);
    final int vw = w;
    final int vh = h;

    final ViewOutlineProvider vop = new ViewOutlineProvider() {
        @Override
        public void getOutline(View view, Outline outline) {
            outline.setRoundRect(0, 0, vw, vh, radius);
        }
    };

    setOutlineProvider(vop);
    setClipToOutline(true);
}
 
Example 3
Source File: ServicesRecyclerViewAdapter.java    From zom-android-matrix with Apache License 2.0 5 votes vote down vote up
@Override
public void onBindViewHolder(final RecyclerView.ViewHolder holder, final int position) {
    Context context = holder.itemView.getContext();

    if (mValues.get(position) instanceof BotEntry) {
        final BotEntry e = (BotEntry)mValues.get(position);

        ViewHolderBot viewHolder = (ViewHolderBot) holder;
        viewHolder.image.setImageResource(e.resIdImage);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            ViewOutlineProvider viewOutlineProvider = new ViewOutlineProvider() {
                @Override
                public void getOutline(View view, Outline outline) {
                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                        int rounding = view.getContext().getResources().getDimensionPixelSize(R.dimen.bot_image_rounding);
                        outline.setRoundRect(0, 0, view.getWidth(), view.getHeight(), rounding);
                    }
                }
            };
            viewHolder.image.setOutlineProvider(viewOutlineProvider);
            viewHolder.image.setClipToOutline(true);
        }
        viewHolder.name.setText(e.resIdName);
        viewHolder.description.setText(e.resIdDescription);
        viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onBotClicked(e.jid,e.nickname);
            }
        });
    }
}
 
Example 4
Source File: ShapeableImageView.java    From material-components-android with Apache License 2.0 5 votes vote down vote up
@Override
public void getOutline(View view, Outline outline) {
  if (shapeAppearanceModel != null && shapeAppearanceModel.isRoundRect(destination)) {
    destination.round(rect);
    float cornerSize =
        shapeAppearanceModel.getBottomLeftCornerSize().getCornerSize(destination);
    outline.setRoundRect(rect, cornerSize);
  }
}
 
Example 5
Source File: FilterMenuLayout.java    From FilterMenu with Apache License 2.0 5 votes vote down vote up
@Override
public void getOutline(View view, Outline outline) {
    int radius = (int) (collapsedRadius + (expandedRadius - collapsedRadius) * expandProgress);
    Rect area = new Rect(
            center.x - radius,
            center.y - radius,
            center.x + radius,
            center.y + radius);
    outline.setRoundRect(area, radius);
}
 
Example 6
Source File: TelegramLoginButton.java    From TGPassportAndroidSDK with MIT License 4 votes vote down vote up
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
public void getOutline(Outline outline){
	outline.setRoundRect(getBounds(), getBounds().height()/2f*radiusPercent);
}
 
Example 7
Source File: RoundRectDrawable.java    From Slice with Apache License 2.0 4 votes vote down vote up
@Override
public void getOutline(Outline outline) {
    outline.setRoundRect(mBoundsI, mRadius);
}
 
Example 8
Source File: CircleImageView.java    From enjoyshop with Apache License 2.0 4 votes vote down vote up
@Override
public void getOutline(View view, Outline outline) {
    Rect bounds = new Rect();
    mBorderRect.roundOut(bounds);
    outline.setRoundRect(bounds, bounds.width() / 2.0f);
}
 
Example 9
Source File: CircleImageView.java    From Aurora with Apache License 2.0 4 votes vote down vote up
@Override
public void getOutline(View view, Outline outline) {
    Rect bounds = new Rect();
    mBorderRect.roundOut(bounds);
    outline.setRoundRect(bounds, bounds.width() / 2.0f);
}
 
Example 10
Source File: CircleImageView.java    From FastAndroid with Apache License 2.0 4 votes vote down vote up
@Override
public void getOutline(View view, Outline outline) {
    Rect bounds = new Rect();
    mBorderRect.roundOut(bounds);
    outline.setRoundRect(bounds, bounds.width() / 2.0f);
}
 
Example 11
Source File: RevealOutlineAnimation.java    From LaunchEnr with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void getOutline(View v, Outline outline) {
    outline.setRoundRect(mOutline, mOutlineRadius);
}
 
Example 12
Source File: SegmentedButtonGroup.java    From SegmentedButton with Apache License 2.0 4 votes vote down vote up
@Override
public void getOutline(View view, Outline outline) {
    outline.setRoundRect(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight(), radius);
}
 
Example 13
Source File: RoundRectDrawable.java    From Slice with Apache License 2.0 4 votes vote down vote up
@Override
public void getOutline(Outline outline) {
    outline.setRoundRect(mBoundsI, mRadius);
}
 
Example 14
Source File: SegmentedButtonGroup.java    From SegmentedButton with Apache License 2.0 4 votes vote down vote up
@Override
public void getOutline(final View view, final Outline outline)
{
    outline.setRoundRect(0, 0, view.getWidth(), view.getHeight(), radius);
}
 
Example 15
Source File: RoundRectDrawable.java    From Nimingban with Apache License 2.0 4 votes vote down vote up
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
public void getOutline(@NonNull Outline outline) {
    outline.setRoundRect(mBoundsI, mRadius);
}
 
Example 16
Source File: RoundRectFrameLayout.java    From EnhancedScreenshotNotification with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void getOutline(View view, Outline outline) {
    final Rect clipPath = new Rect();
    view.getLocalVisibleRect(clipPath);
    outline.setRoundRect(clipPath, mCornerRadius);
}
 
Example 17
Source File: CircleImageView.java    From Shipr-Community-Android with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void getOutline(View view, Outline outline) {
    Rect bounds = new Rect();
    mBorderRect.roundOut(bounds);
    outline.setRoundRect(bounds, bounds.width() / 2.0f);
}
 
Example 18
Source File: RoundRectDrawable.java    From OptionRoundCardview with Apache License 2.0 4 votes vote down vote up
@Override
public void getOutline(Outline outline) {
    outline.setRoundRect(mBoundsI, mRadius);
}
 
Example 19
Source File: CardView.java    From Dashchan with Apache License 2.0 4 votes vote down vote up
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
public void getOutline(Outline outline) {
	outline.setRoundRect(boundsI, radius);
}
 
Example 20
Source File: CircleImageView.java    From Travel-Mate with MIT License 4 votes vote down vote up
@Override
public void getOutline(View view, Outline outline) {
    Rect bounds = new Rect();
    mBorderRect.roundOut(bounds);
    outline.setRoundRect(bounds, bounds.width() / 2.0f);
}