- 註冊時間
- 2013-4-16
- 最後登錄
- 2023-7-6
- 閱讀權限
- 100
- 積分
- 26424
- 精華
- 0
- 帖子
- 8169
|
如何畫圓。
How to draw a Circle.- private Context context;
- public FrameLayout fLayout;
- private Canvas g;
複製代碼- Display display = _context.getDisplay();
- int width = display.getHeight();
- int height = display.getWidth();
- Bitmap bitmap = Bitmap.createBitmap(height, height, Bitmap.Config.RGB_565);
- g = new Canvas(bitmap);
- g.drawColor(Color.WHITE);
- g.drawBitmap(bitmap, 0F, 0F, null);
- Paint paint = new Paint();
- paint.setAntiAlias(true);
- paint.setDither(true);
- paint.setColor(Color.BLUE);
- paint.setStyle(Paint.Style.FILL);
- paint.setStrokeJoin(Paint.Join.ROUND);
- paint.setStrokeCap(Paint.Cap.ROUND);
- paint.setAlpha(0xff);
- paint.setStrokeWidth(1);
- g.drawCircle(height/2, height/2, height/2, paint); //Put your values
- // In order to display this image, we need to create a new ImageView that we can display.
- ImageView imageView = new ImageView(_context);
- // Set this ImageView's bitmap to ours
- imageView.setImageBitmap(bitmap);
- fLayout.addView(imageView);
複製代碼 |
|