ondraw

Passing x,y coordinates of drawCircle() to drawLine()

瘦欲@ 提交于 2019-12-13 05:47:46
问题 I am trying to draw line between two circles. I have drawn two circles on canvas, These two circles have their cx and cy points. I want to pass these cx and cy of both circles to drawLine()'s startx,starty and stopx,stopy. So that a line should be drawn between these two circles. These two circles can be parallel to each other or horizontal to each other. What I have planned so far is that I should apply action-listener to circles in order to get their x and y coordinates. The problem I am

How to create Clickable Rectangles?

江枫思渺然 提交于 2019-12-13 04:42:37
问题 Im drawing an indoor map using DrawRect method. I want to identify each rectangle by the user's OnTouch Event.How can i make it happen? I want to know if i can use the drawn Rectangles as independent objects Where i can identify them uniquely. UPDATED I tried this. But it gives me errors.How can i create a new intent withing the for loop?? :( ArrayList<Rect> rectangles = new ArrayList<Rect>(); {rectangles.add(new Rect(232,78,419,238)); rectangles.add(new Rect(285,27,524,239)); rectangles.add

How to prevent Thread.Sleep in onDraw affecting other Activities?

徘徊边缘 提交于 2019-12-13 03:27:18
问题 I have a custom View class which is drawing images. The problem is that when I use Thread.sleep(200); in the onDraw method, it also affects the XML elements that are in the same activity. So I have to wait 200 miliseconds untill something happens. MainPage extends Activity implements OnClickListener{ onCreate(...){ RelativeLayout rl = (RelativeLayout) findViewById(R.id.main_rl); rl.addView(new CustomView(this)); } onClick(View v){ switch(v.getId){ ... }; } } CustomView extends View{ onDraw(){

android view viewgroup invalidate ondraw and draw

核能气质少年 提交于 2019-12-12 14:50:08
问题 We're trying to write our own MapView, and I'm trying to figure out how adding overlays to the mapview causes them to get drawn in other mapping APIs I've got a MapView that extends ViewGroup. I think I've figured out that calling MapView.invalidate() causes the mapview's dispatchDraw method to be called. Does that sound correct? If that's true, when is the onDraw and draw method of the mapview called? More importantly is all this view and which methods called when stuff documented well

onDraw fill shape create with canvas.drawLine

☆樱花仙子☆ 提交于 2019-12-12 09:08:59
问题 i draw 4 lines (canvas.drawLine) in order to draw a rectangle. Is there any possibility to fill the area of the rectangle? (I know that android have a rectDraw. Mine is only curiosity) thanks in advance. ok.. I ve also a path created a path segment. Following the code.. Please can u explain how fill the internal area? `Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); paint.setStrokeWidth(2); paint.setColor(android.graphics.Color.RED); paint.setStyle(Paint.Style.FILL_AND_STROKE); paint

Execute the code inside onDraw() only after the click in view

◇◆丶佛笑我妖孽 提交于 2019-12-12 05:21:04
问题 I have a class that extends a view. This class is called in xml to build my view. Now the view call the onDraw automatically the onDraw function on loaded. But how i can do what is do on onDraw() function only after i click in that view?? In conclusion i need to execute the code inside onDraw() only after the click in view. DrawView.java: public class DrawView extends View { Paint mPaint = new Paint(); Context context; public DrawView(Context context, AttributeSet attrs){ super(context, attrs

Recreate an object without deleting the last one

徘徊边缘 提交于 2019-12-11 14:10:13
问题 I'm creating an app that allows user to draw on the screen. My code actually creates a Path and next creates a line. But this when the user takes up his finger of the screen and goes to another part of the screen it make a line as it happen in the next video. http://youtu.be/CBv1wtUC2g4 The following code is the code of the drawview. public class DrawView extends View implements OnTouchListener { private static final String TAG = "DrawView"; List<Point> points = new ArrayList<Point>(); Paint

Android : click / touch event not working after canvas translate

馋奶兔 提交于 2019-12-11 09:50:48
问题 I have a FrameLayout that contains several ImageView. On the main activity, I record the touch events in order to move my FrameLayout and the images inside with the finger (drag). For doing so, I am calling canvas.translate(x,y) inside the onDraw of the framelayout which is called by a invalidate() in the activity touch event handler. Everything works like a charm except that after the translate, I am not able to click on my ImageView. In fact, the click listener of each image is still at the

Canvas is drawing too slowly

允我心安 提交于 2019-12-11 08:01:27
问题 I am working on an app that allows stepping through video frames (bitmaps). It also has the capability to play back the frames, one after another, as though you are actually viewing a video composed of the frames. I have one ImageView that is showing one bitmap at a time. The problem I am having is that drawing the image to the ImageView (we're talking just a call to super.onDraw()) is taking roughly 30ms. Since the frames need to be playing back at their original framerate, this is a problem

SurfaceView, onDraw and postInvalidate() something wrong

99封情书 提交于 2019-12-11 06:49:45
问题 App behave itself strangely. I have a class extends the SurfaceView and implements SurfaceHolder.Callback . I tried 3 options of code and only one works like i need (but I'm doubt that it is a right solution) and other have different behavior. So, my question is why and what is wrong and if "right" solution is wrong, so why it's work... Right for all: I tried setWillNotDraw(boolean flag) flag(true/false) In manifest set android:changeConfiguration="orientation" In main layout set background