Wrapping long text on an Android Canvas-ThrowExceptions

Exception or error: I have a custom control that is doing a lot of 2D drawing straight to the canvas. Some of this drawing is text, so I am using the Canvas.drawText() method. I want to draw the text within some bounds – a top-left, certain maximum width, and a maximum number of lines. After …

android how to draw a bitmap on canvas semi transparent-ThrowExceptions

Exception or error: I have tried to modify a Paint variable, but have been unsuccessful – how can I make a bitmap appear “semi-transparent”? How to solve: canvas.drawColor(Color.WHITE); BitmapDrawable bd = (BitmapDrawable) getResources().getDrawable(R.drawable.loading); Bitmap bm = bd.getBitmap(); Paint paint = new Paint(); paint.setAlpha(60); //you can set your transparent value here canvas.drawBitmap(bm, 0, 0, paint); ### …

Android Canvas Redo and Undo Operation-ThrowExceptions

Exception or error: I am working on a drawing project. My code is working perfectly other than canvas redo and undo operations. My undo operation removes paths from the paths ArrayList and saves to the undonePaths ArrayList, and the redo operation removes the last element from undonePaths and saves to paths. Here’s my code: import …

How to draw filled triangle on android Canvas-ThrowExceptions

Exception or error: I have class MyView that extends View class. MyView should draw filled triangle. I drew a triangle but I cannot get it filled. This is my onDraw() method: @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); Paint paint = new Paint(); paint.setColor(android.graphics.Color.BLACK); canvas.drawPaint(paint); paint.setStrokeWidth(4); paint.setColor(android.graphics.Color.RED); paint.setStyle(Paint.Style.FILL_AND_STROKE); paint.setAntiAlias(true); Point a = new Point(0, 0); …

android – Bezier curve and canvas-ThrowExceptions

Exception or error: How I can draw bezier curve in canvas. I have only start point and end point. I want to draw line from start point to end point. How I can do this? How to solve: You can use Path.quadTo() or Path.cubicTo() for that. Examples can be found in the SDK Examples (FingerPaint). …

android – draw object/image on canvas-ThrowExceptions

Exception or error: Is there another way to draw an object on a canvas in android? This code inside draw() doesn’t work: Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.pushpin); canvas.drawBitmap(bmp, screenPts.x, screenPts.y-50, null); Well actually, it’s working on my 1st code but when I’ve transfered this to another class called MarkOverlay, it’s not working anymore. markerOverlay = …

android – Canvas.clipPath(Path) not clipping as expected-ThrowExceptions

Exception or error: I’m trying to clip a canvas drawing operation to an arc-shaped wedge. However, I’m not getting the intended result after setting the clipping path to the canvas. For illustration, here is what I’m doing: path.reset(); //Move to point #1 path.moveTo(rect.centerX(), rect.centerY()); //Per the documentation, this will draw a connecting line from the …