Questions tagged [ondraw]

onDraw is an event that is used in multiple languages/frameworks to notify the application that something needs to be (re)drawn.

onDraw is an event that is used in multiple languages/frameworks to notify the application that something needs to be (re)drawn.

The exact implementation and usage is depending on the framework implementation

Examples are:

662 questions
6
votes
2 answers

Efficient 2D drawing in Android

I have searched for quite a few hours and have not been able to find a concise definite andswer to my question. I have an application where I need to draw a sports field (including all pitch lines) to the screen. So far, I have extended the…
Sonoman
  • 3,379
  • 9
  • 45
  • 61
6
votes
2 answers

Android custom view not repainting, though onDraw is being called

I have custom view called ArrowView. When this view is part of a layout which is part of an ArrayAdapter everything is fine. (It is repainted as the underlying data changes.) When I use that same layout as part of another Adapter the ArrowView…
fadedbee
  • 42,671
  • 44
  • 178
  • 308
6
votes
2 answers

Drawing on Canvas outside the onDraw() method

Here's my OnDraw() method void onDraw(Canvas canvas) { mCanvas = canvas; //invalidate(); int x = 0; Iterator it = mNextUpQueue.iterator(); while(it.hasNext()){ mCanvas.drawBitmap(it.next().getNext(),…
user3396442
  • 67
  • 2
  • 4
6
votes
3 answers

Canvas shows transparent part of bitmap in black color - Android

In my android application, I want to draw two images - img1 and img2. At first, I will draw img2 on Canvas. After that i will draw img1 on Canvas which will overlap img2. Img1 contains transparent part. The problem is that, transparent part of img1…
Zankhna
  • 4,570
  • 9
  • 62
  • 103
6
votes
1 answer

Avoiding object allocations in onDraw() (StaticLayout)?

I have a custom view which I quickly learned to not do object allocations in and moved all my Paint allocations into a different method, fine. I need to use a StaticLayout however for some text that had some spannable 'stuff' applied. …
Anthony
  • 109
  • 2
  • 6
5
votes
1 answer

Android onDraw() executing on all Views?

Here is a weird behavior that I don't understand about custom views. I have two views in a frame layout, one on top of the other. The views are simple and I've made them just for a short test public class View1 extends View { .... @Override …
Alin
  • 14,809
  • 40
  • 129
  • 218
5
votes
4 answers

Ondraw for a custom view is looping infinitely android

OnDraw function for my custom View is being called infinitely and is looping !! What could be possible reason?? Here is my custom view:- public class Balls extends View{ private static final String TAG = "BallsView"; private int mMode =…
Ruchira
  • 935
  • 2
  • 15
  • 30
5
votes
3 answers

Android SurfaceView not showing onDraw

For simpleness of the question, I'm drawing an integer on a SurfaceView which increases by 1 every draw. The increasing actually happens, as I can see on the System.out. The text on the screen stays on '0'. Who can tell me what I'm doing…
nhaarman
  • 98,571
  • 55
  • 246
  • 278
5
votes
1 answer

Diagonal line appears thicker than straight line when using path.lineTo()

I've created a class that extends Shape in order to draw custom shapes (rectangle with cut off corners) for the background of my buttons. The problem I have is that lines drawn as a diagonal appear much thicker than straight lines: How can I make…
MichaelStoddart
  • 5,571
  • 4
  • 27
  • 49
5
votes
1 answer

Custom Knob View for controlling Volume?

I want to show progress bar around knob. After following this tutorial I created this knob it is working fine. But How could i modify the above knob to look like the second image Running code…
Zar E Ahmer
  • 33,936
  • 20
  • 234
  • 300
5
votes
1 answer

android paint text overlapping

Trying to draw vehicle gauges in android using Paint and ondraw() using a opensource code. Gauges worked pretty well but had problems with android 4 and above. After that made a change to Paint object by setting setLinearText(true) which made things…
Madhu V Swamy
  • 263
  • 2
  • 14
5
votes
6 answers

Am I invalidating the entire screen on every call?

I am new to Android Development and reading the book Hello Android. It uses a Sudoku example, and the code that I am referring to is here. In this , onTouchScreen, it calls select method, that calls invalidate twice. The question is that, on…
Kraken
  • 23,393
  • 37
  • 102
  • 162
5
votes
1 answer

Android canvas - Draw a hole

Is it possible to realize the following picture in Android with canvas? I want to have a hole and not only a Circle over the red layer which is yellow colored. I tried this (and failed) with the following Code in my…
yannickpulver
  • 2,235
  • 1
  • 23
  • 31
5
votes
2 answers

How to draw triangle shape and add it into relative or linear layout android

I am developing small android application in which I m using my custom linear layout class. In that class i tried to draw one small triangle and tried to include it in to my linear layout but I m not able to do that. I tried it in following ways…
nilkash
  • 7,408
  • 32
  • 99
  • 176
5
votes
0 answers

Android Custom View onMeasure onDraw lifecycle

I have created a custom view in android which extends View. I override the onDraw() method and do my painting to the canvas there - no problem. I understand that I should override the onMeasure() method as well and call setMeasuredDimension(width,…
Dean Wild
  • 5,886
  • 3
  • 38
  • 45
1 2
3
44 45