Questions tagged [android-canvas]

The Android Java Canvas (android.graphics.Canvas)

This is the tag for the Android Java Canvas, android.graphics.Canvas (official documentation).

If your question is about HTML5 (JavaScript) Canvas on Android devices please tag it and .

3799 questions
48
votes
4 answers

Using clipRect - explanation

public class POCII extends Activity { myView mv = new myView(this); @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(mv); } } class myView…
Namratha
  • 16,630
  • 27
  • 90
  • 125
42
votes
1 answer

How to make any view to draw to canvas?

I have a short question: Suppose I have a (mutable) bitmap that I need to modify (add images, texts, etc...) . Instead of messing around with many special classes for drawing to the canvas (paint, canvas, matrices and so on), I was thinking why not…
android developer
  • 114,585
  • 152
  • 739
  • 1,270
41
votes
5 answers

Android: Drawing a canvas to an ImageView

I'm new to android programming and what I'm trying to figure out is this; In my layout i have a TextView, ImageView, and Button, all on a vertically oriented LinearLayout. I want to be able to dynamically draw circles in the ImageView, without…
sil
  • 463
  • 2
  • 5
  • 5
39
votes
5 answers

Understanding how actually drawRect or drawing coordinates work in Android

I am trying to draw a rectangle over a canvas and I am facing troubles to understand the in-depth of rectangle draw of Android. I've read tutorials and every possible but I am stuck. Here in the image , the red rectangle is my target. Irrespective…
Abhishek Choudhary
  • 8,255
  • 19
  • 69
  • 128
36
votes
8 answers

Adding a colored background with text/icon under swiped row when using Android's RecyclerView

EDIT: The real problem was that my LinearLayout was wrapped in another layout, which caused the incorrect behavior. The accepted answer by Sanvywell has a better, more complete example of how to draw a color under swiped view than the code snippet I…
35
votes
3 answers

PorterduffXfermode: Clear a section of a bitmap

The goal is to draw a bitmap and over the top of something, and draw shapes that ERASE the underlying area of the bitmap. I have a proof of concept to try and understand how I should go about this. I have found numerous hints about…
btalb
  • 6,937
  • 11
  • 36
  • 44
34
votes
8 answers

SurfaceView flashes black on load

I have a drawing app that takes about 2-5 seconds to load the drawing for complicated drawings (done via an AsyncTask). For a better user experience, during this time I flash the stored PNG version of the drawing I have from the app directory as an…
Unpossible
  • 10,607
  • 22
  • 75
  • 113
33
votes
5 answers

Draw smoothly scaled bitmaps on Canvas

This is how I draw Bitmap on Canvas in my Android app: canvas.save(); canvas.scale(scale, scale, x, y); canvas.drawBitmap(bitmap, x, y, null); canvas.restore(); However the Bitmap is not scaled smoothly, no anti-aliasing is performed. How can I…
fhucho
  • 34,062
  • 40
  • 136
  • 186
32
votes
6 answers

Error : RuntimeException at DisplayListCanvas.throwIfCannotDraw

My application work very well on nougat emulator and many devices, but i found this exception in google play crash reporter, I don't know why it happened, The exception causes with nougat devices ++ only. the exception : …
user7913931
31
votes
7 answers

Slow App with Background image

I am making a small game for android. It is working smoothly when its working on a white background but when i want to put a background image, its becoming slower and slower. First i tried to add it as a layout background image but it was very slow,…
koraxis
  • 801
  • 2
  • 12
  • 22
31
votes
4 answers

How to draw a path on an Android canvas with animation?

I'm making an Android app and I've got a tricky thing to do. I need to draw a path on a canvas but the drawing should be animated (ie. drawing point after point with a slight delay). Is it possible to make something like this using Android SDK? If…
Romain Piel
  • 11,017
  • 15
  • 71
  • 106
30
votes
3 answers

Using method -canvas.drawBitmap(bitmap, src, dst, paint)

I need to draw a bitmap inside of a specified rectangle. Why is it not drawn? canvas.drawBitmap(MyBitmap, null, rectangle, null)
Kohler Fryer
  • 764
  • 2
  • 8
  • 17
30
votes
4 answers

draw rounded edge arc in android with embossed effect

I am trying to develop a custom component i.e. arc slider, I am done with the arc and the thumb but not able to figure out how can I draw the rounded edge arc and also the embossed effect in it. at the moment the slider looks something like…
Shashank
  • 1,087
  • 1
  • 14
  • 26
29
votes
4 answers

Android canvas draw line - make the line thicker

This seems like it should be somewhat trivial, however in my android app, I am using canvas to draw a series of lines that are connected together. For some reason my lines are very very faint and thin. I was wondering how can I make my lines…
user859348
  • 359
  • 1
  • 3
  • 13
28
votes
6 answers

Android : Draw Circle With Text Inside

I need to draw three circles in my fragment ,the circles differ in size, I refer this link The result i obtained is this This is my XML Code : UPDATED
edwin
  • 7,985
  • 10
  • 51
  • 82