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
10
votes
2 answers

Android - calculate arc angle

I have an arc and i wish to draw scale marks at 0, 45, 90, 135, 180 degrees, can anyone help me with the math needed to achive the x,y of points 5 and 30 on this sketch?: here is my code for drawing the 1 scale mark. private void…
Ziv Kesten
  • 1,206
  • 25
  • 41
10
votes
4 answers

Android: How to use the onDraw method in a class extending Activity?

As a beginner, I've been building a simple counter application using a simple layout xml and a class called 'Counter', which derives (extends) from the class Activity. Now, I want to load a bitmap (png file) to place next to the counter. I've been…
Turbosheep
  • 183
  • 1
  • 2
  • 13
10
votes
5 answers

Android draw using SurfaceView and Thread

I am trying to draw a ball to my screen using 3 classes. I have read a little about this and I found a code snippet that works using the 3 classes on one page, Playing with graphics in Android I altered the code so that I have a ball that is moving…
Morten Høgseth
  • 338
  • 2
  • 4
  • 17
10
votes
2 answers

How to set canvas size?

I have a class named SeatsPanel where I draw seats (using drawRect) in the onDraw method. The onDraw method uses Canvas as a parameter, but how do you set size of the Canvas? The reason why I'm asking this question is because this class is being…
Aerial
  • 1,185
  • 4
  • 20
  • 42
9
votes
2 answers

why my invoke of Canvas.drawText() just doesn't work

Hi all: I'm writing a class that inherit from TextView, and override its onDraw() method, but in the method, my invoke of canvas.drawText() doesn't seems to work, the code just like below: protected void onDraw(Canvas canvas) { //…
Vince.Wu
  • 870
  • 1
  • 10
  • 17
8
votes
1 answer

How to update Android Views upon modifications?

I have some methods in my View that modify some of the shapes that are drawn when called. In Java in order to make sure the component is updated I would call repaint(). Is there something that will make sure my view is updated correctly? I had read…
StartingGroovy
  • 2,802
  • 9
  • 47
  • 66
8
votes
1 answer

Flash in an Android WebView - layering issue

I am trying to have interactive buttons in an android WebView that contains flash. As a test, I set up a HTML to load in a flash through with a set x/y size. public class webz extends WebView { private Drawable image; public webz(Context context,…
corey
  • 498
  • 3
  • 10
8
votes
1 answer

Is it a good programming practice to call invalidate() inside onDraw()?

Is it a good programming practice to call invalidate() inside onDraw()? As per my understanding, calling invalidate() inside onDraw() is expensive and is not required if there is no change to the canvas. Is invalidate() equivalent to an…
hsbgowd
  • 178
  • 2
  • 7
8
votes
1 answer

How to draw onto a view canvas without upscaling artifacts when the view parent has a scale factor?

When drawing onto a canvas in a View's onDraw method you don't know about any scale factor of its parent. This leads to all views and their drawings being up/down scaled whereby one can explore "pixelized" drawings. Example: So let's say we've got a…
Lars Blumberg
  • 19,326
  • 11
  • 90
  • 127
7
votes
2 answers

How to define a pixel independent height in an onDraw() method

I have extended View to build a custom widget. I would like to define the height of the widget with an independ pixel unit. I think it could be done by multiplying the pixel density by the desired height , but i don't know how to do that. What i…
grunk
  • 14,718
  • 15
  • 67
  • 108
7
votes
1 answer

onDraw Custom View inside a Scrollview

I have a custom view (width = 2000) inside a Horizontal Scrollview (width = 480). So there's a region that is scrollable. When onDraw() is called, the dirty rectangle (returned by getClipBounds()) returns the whole view's dimensions, so I draw the…
Merlevede
  • 8,140
  • 1
  • 24
  • 39
7
votes
5 answers

Draw overlay (HUD) on Android VideoView?

I have a custom view that draws HUD: Here is my layout:
Danpe
  • 18,668
  • 21
  • 96
  • 131
7
votes
1 answer

Android Canvas and Hardware Acceleration?

Hi all I was wondering if it was possible to draw to an offscreen Canvas / Bitmap and take advantage of hardware acceleration or do I have to draw inside the onDraw() method of the View For example I draw to an offscreen Bitmap by doing the…
neptune692
  • 353
  • 1
  • 4
  • 12
7
votes
6 answers

Drawing a rectangle using a move gesture

I am trying to create a rectangle, but this is what happens when I move from starting coordinates towards the end coordinates , actually I want to show the progress when the user moves from one point to other as well.This is what I would like to…
Yauraw Gadav
  • 1,706
  • 1
  • 18
  • 39
6
votes
1 answer

Draw a text on a circle path in android

I need to draw a text on a circle path. I have tried the drawTextOnPath() method. But for texts like "fertile window" in the image attched, the text rotates and is not readable. Code I have used : customPath2.addArc(mCircleRectF, 30F, 64.28F); …
Sahana Prabhakar
  • 581
  • 1
  • 8
  • 21
1
2
3
44 45