Android之Canvas的drawRoundRect()

1 问题

Canvas的drawRoundRect()函数怎么用

public void drawRoundRect(RectF rect, float rx, float ry, Paint paint)
功能:该方法用于在画布上绘制圆角矩形,通过指定RectF对象以及圆角半径来实现。

float rx:生成圆角的椭圆的X轴半径
float ry:生成圆角的椭圆的Y轴半径

 

 

 

2 代码实现

 TestView.java文件如下

package com.onemt.sdk.circle;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

public class TestView extends View {


    private Paint mPaint;
    private RectF rectf;
    public TestView(@NonNull Context context) {
        super(context);
        init();
    }

    public TestView(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs)

你可能感兴趣的:(Andriod,积累,android,canvas)