繁体   English   中英

用箭头编程绘制气泡

[英]Draw bubble programmatically with arrow

我正在从Stackoverflow实现以下类

https://stackoverflow.com/a/20811323/1936925

但我需要这样的泡沫

在此处输入图片说明

我正在尝试很多,但是不知道该怎么做。

为了获得上述可绘制对象,我需要进行哪些编辑。

尝试这个:

public Bitmap overlay(Bitmap image, String content) {
        BitmapFactory.Options options = new BitmapFactory.Options();
        options.inScaled = false;
        options.inPreferredConfig = Bitmap.Config.ARGB_8888;
        //My bg bitmap, use yours
        Bitmap background = Bitmap.createScaledBitmap(BitmapFactory.decodeResource(MapActivity.context.getResources(), R.drawable.marker_base, options), marker_width, marker_height, true);
        //your red bitmap here
        Bitmap bmOverlay = Bitmap.createBitmap(background.getWidth(), background.getHeight(), background.getConfig());
        Canvas canvas = new Canvas(bmOverlay);
        Paint paint = new Paint();
        paint.setFilterBitmap(true);
        canvas.drawBitmap(background, new Matrix(), paint);
        canvas.drawBitmap(image, 3, 3, paint);

        if (content != null)
        {
            //Use your TextSize and Color and paddings
            paint = new Paint();
            paint.setColor(Color.BLACK);
            if (content.length() < 11)
                paint.setTextSize(13);
            else
                paint.setTextSize(10);
            //30 / 28, 17 - my paddings
            canvas.drawText(content, (content.length() < 11)?30:28, 17, paint);
        }
        return bmOverlay;
    }

解决了

mPointer.rLineTo(80, 0);
mPointer.rLineTo(0, 60);
mPointer.rLineTo(-(80), -60);
mPointer.close();

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM