代码之家  ›  专栏  ›  技术社区  ›  Gunaseelan

画布drawTextOnPath和保存视图

  •  0
  • Gunaseelan  · 技术社区  · 7 年前

    当我在画布上用

    //mTextPaint initialized while initialize the view.
    mTextPaint = new TextPaint();
    mTextPaint.setAntiAlias(true);
    mTextPaint.setColor(color);
    
    //iPath move/line to some point on onTouchEvent()
    canvas.drawTextOnPath(text, iPath, 0, 0, mTextPaint);
    

    enter image description here

    当我使用,

    try {
        fos = new FileOutputStream(fname);
        v.getDrawingCache().compress(Bitmap.CompressFormat.JPEG, 100, fos);
    } catch (Exception ex) {
        Toast.makeText(this, "Error Saving Image",
                Toast.LENGTH_LONG).show();
    }
    

    注: setDrawingCacheEnabled(true); 在初始化视图时添加。
    enter image description here

    任何关于为什么会发生这种情况以及如何克服这个问题的想法。

    1 回复  |  直到 7 年前
        1
  •  0
  •   Gunaseelan    7 年前

    问题是默认字体。默认字体是 Typeface.SANS_SERIF .

    我换了 Typeface.SERIF 通过使用以下代码及其工作原理。

    mTextPaint.setTypeface(Typeface.SERIF);