object(mysqli_result)#13 (5) { ["current_field"]=> int(0) ["field_count"]=> int(25) ["lengths"]=> NULL ["num_rows"]=> int(1) ["type"]=> int(0) } 如何畫圓。How to draw a Circle. - 程序員論壇 - Powered by Discuz!

程序員論壇

標題: 如何畫圓。How to draw a Circle. [打印本頁]

作者: GreenCup    時間: 2021-4-1 14:38
標題: 如何畫圓。How to draw a Circle.
如何畫圓。
How to draw a Circle.
  1. private Context context;
  2.     public FrameLayout fLayout;
  3.     private Canvas g;
複製代碼
  1. Display display = _context.getDisplay();

  2.         int width = display.getHeight();
  3.         int height = display.getWidth();

  4.         Bitmap bitmap = Bitmap.createBitmap(height, height, Bitmap.Config.RGB_565);

  5.         g = new Canvas(bitmap);
  6.         g.drawColor(Color.WHITE);
  7.         g.drawBitmap(bitmap, 0F, 0F, null);

  8.         Paint paint = new Paint();

  9.         paint.setAntiAlias(true);
  10.         paint.setDither(true);
  11.         paint.setColor(Color.BLUE);
  12.         paint.setStyle(Paint.Style.FILL);
  13.         paint.setStrokeJoin(Paint.Join.ROUND);
  14.         paint.setStrokeCap(Paint.Cap.ROUND);
  15.         paint.setAlpha(0xff);
  16.         paint.setStrokeWidth(1);

  17.         g.drawCircle(height/2, height/2, height/2, paint); //Put your values

  18.         // In order to display this image, we need to create a new ImageView that we can display.
  19.         ImageView imageView = new ImageView(_context);

  20.         // Set this ImageView's bitmap to ours
  21.         imageView.setImageBitmap(bitmap);

  22.         fLayout.addView(imageView);
複製代碼





歡迎光臨 程序員論壇 (http://program.thesmartfire.com/) Powered by Discuz! X2.5