文本视图文本没有正确膨胀android画布

问题描述

enter image description here

我正在画布上绘制文本,但它没有正确地对文本进行膨胀。笔划文本字体显示而不是纯色。附上代码图片
我不知道它的确切根本原因。请帮我解决这个问题。提前致谢。

 paint.setColor(Color.TRANSPARENT);
                    key.getKeyDrawable().draw(canvas);
                    //Initialize the note area
                    Rect r = key.getKeyDrawable().getBounds();
                    int sideLength = (r.right - r.left) / 2;
                    int left = r.left + sideLength / 2;
                    int top = r.bottom - sideLength - sideLength / 3;
                    int right = r.right - sideLength / 2;
                    int bottom = r.bottom - sideLength / 3;

                    square.set(left,top,right,bottom);
                    canvas.drawRoundRect(square,6f,paint);
                    paint.setColor(Color.BLACK);
                    paint.setTextSize(sideLength / 1.8f);
                    Paint.FontMetricsInt fontMetrics = paint.getFontMetricsInt();
                    int baseline = (int) ((square.bottom + square.top - fontMetrics.bottom - fontMetrics.top) / 2);
                    paint.setTextAlign(Paint.Align.CENTER);

                    canvas.drawText(key.getLetterName(),square.centerX(),baseline,paint);

                    key.setCenterX(square.centerX());
                    key.setBaseLine(baseline);
                    key.setPaint(paint);
                    key.setCanvas(canvas);

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)