0

我尝试使用 drawCircle(...) 方法在 Canvas 的帮助下创建一个圆圈。但最后为什么要给我一个椭圆而不是一个圆?我怎样才能得到“真正的”圈子?

Bitmap bitmap = Bitmap.createBitmap((int) (widthView), heightView, Bitmap.Config.ARGB_8888);
  Canvas canvas = new Canvas(bitmap);
  Paint paint = new Paint();
  paint.setColor(Color.parseColor("#FF950000"));
  paint.setAntiAlias(true);
  paint.setStyle(Style.FILL);
  canvas.drawRect(0.0f, 0.0f, widthView, heightLevel, paint);
  paint.setColor(Color.parseColor("#FFD4A503"));
  canvas.drawRect(0.0f, heightLevel, widthView, 2 * heightLevel, paint);
  paint.setColor(Color.parseColor("#FF4A7816"));
  canvas.drawRect(0.0f, 2 * heightLevel, widthView, 3 * heightLevel,
    paint);
  paint.setColor(Color.parseColor("#FFFFFFFF"));
  canvas.drawCircle(30 * density, getLevelHeight(1), 20f, paint);  graphicView.setBackgroundDrawable(new BitmapDrawable(getResources(),
    bitmap));

结果:

连结 4

在此处输入图像描述

华为 G500Pro (Shine)

在此处输入图像描述

4

1 回答 1

0

您应该使用setImageBitmap(Bitmap).setBackgroundDrawable()

此外,setBackgroundDrawable()已被弃用。

于 2013-07-17T11:53:25.650 回答