程序員論壇

 找回密碼
 立即註冊
搜索
熱搜: 活動 交友 discuz
查看: 1450|回復: 0
打印 上一主題 下一主題

如何畫圓。How to draw a Circle.

[複製鏈接]

8166

主題

1

好友

2萬

積分

版主

Rank: 7Rank: 7Rank: 7

跳轉到指定樓層
樓主
發表於 2021-4-1 14:38:32 |只看該作者 |倒序瀏覽
如何畫圓。
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);
複製代碼
回復

使用道具 舉報

您需要登錄後才可以回帖 登錄 | 立即註冊

程序員論壇

GMT+8, 2024-9-20 10:54 , Processed in 0.031791 second(s), 19 queries .

Powered by Discuz! X2.5

© 2001-2012 Comsenz Inc.

回頂部
HK Piece免費建立你的網上商店
Pocket Money Easy