Android绘制rect,在自定义视图上只有曲线一侧

时间:2017-02-08 21:31:14

标签: android android-canvas android-view android-drawable

我需要在try{ $accessToken="Bearer xxxxxxxxxxxxx"; $client = new GuzzleHttp\Client(); $request=$client->request('GET', 'https://api.mocaplatform.com/v2/meta/domains/'); $request->addHeader('Authorization', $accessToken); $query = $request->getQuery(); $query->set('oauth_token', $accessToken); $response = $request->send(); $response = $response->json(); return $response; } catch (GuzzleHttp\Exception\BadResponseException $e) { #guzzle repose for future use $response = $e->getResponse(); $responseBodyAsString = $response->getBody()->getContents(); print_r($responseBodyAsString); } return 'hola'; } android上绘制这个形状(rect或任何方式)。只有一个曲线边。 1个纯色,弯曲侧透明。怎么画这个?

SELECT COUNT(*) FROM negocio N INNER JOIN posts P
ON P.id_negocio = N.id WHERE P.tipo_post = 'Post' 
AND P.estado_post = 'Disenador'
像这样:

enter image description here

感谢。

1 个答案:

答案 0 :(得分:2)

溶液:

更新:

public class MyView extends View {

    private Paint paint;
    private Path path;

    public MyView(Context context) {
        super(context);
        init();
    }

    public void init() {

        path = new Path();

        paint = new Paint();
        paint.setAntiAlias(true);
        paint.setDither(true);
        paint.setStyle(Paint.Style.FILL);
        paint.setColor(Color.RED);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);

        canvas.drawColor(Color.TRANSPARENT);
        paint.setShader(null);

        float width = getWidth();
        float height = getHeight();

        path.moveTo(0, 0);

        path.lineTo(0, height);

        path.lineTo(width, height);

        path.lineTo(width, 0);

        path.cubicTo(4*width/6, 3*height/4, 2*width/6, 3*height/4, 0, 0);

        paint.setColor(Color.RED);
        paint.setStyle(Paint.Style.FILL);
        canvas.drawPath(path, paint);

    }

}