[android-developers] Re: How to draw directly on screen without calling invalidate?

2009-05-06 Thread Sukitha Udugamasooriya

Thank you...


On May 6, 11:21 am, Dianne Hackborn  wrote:
> You can look at the Touch Paint API demo as an example of one approach.
>
> On Tue, May 5, 2009 at 9:04 PM, Sukitha Udugamasooriya 
> wrote:
>
>
>
> > Thanks. Is there a way to save the Canvas object on re-draw that in
> > the onDraw()??
>
> --
> Dianne Hackborn
> Android framework engineer
> hack...@android.com
>
> Note: please don't send private questions to me, as I don't have time to
> provide private support, and so won't reply to such e-mails.  All such
> questions should be posted on public forums, where I and others can see and
> answer them.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: How to draw directly on screen without calling invalidate?

2009-05-05 Thread Dianne Hackborn
You can look at the Touch Paint API demo as an example of one approach.

On Tue, May 5, 2009 at 9:04 PM, Sukitha Udugamasooriya wrote:

>
> Thanks. Is there a way to save the Canvas object on re-draw that in
> the onDraw()??
> >
>


-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: How to draw directly on screen without calling invalidate?

2009-05-05 Thread bra...@gmail.com

Thats how I do it in my apps.

On May 5, 4:30 am, Mariano Kamp  wrote:
> The onDraw() method starts from the scratch every time and so doesn't keep
> your drawings from the last invocation. Instead you would need to save all
> the previous points yourself and use them in onDraw().
>
> On Tue, May 5, 2009 at 9:25 AM, Sukitha Udugamasooriya 
> wrote:
>
>
>
> > I want to draw strokes on my screen when the user touches. Next stroke
> > should be drawn from the end point
> > of the previous stroke.
> > This is my code. What happens here is just only the current stroke is
> > drawn. Previous strokes are vanished? What is wrong here? Please
> > help..
>
> > package src.test;
>
> > import android.app.Activity;
> > import android.content.Context;
> > import android.graphics.Bitmap;
> > import android.graphics.Canvas;
> > import android.graphics.Color;
> > import android.graphics.Paint;
> > import android.os.Bundle;
> > import android.view.MotionEvent;
> > import android.view.View;
> > import android.view.View.OnTouchListener;
>
> > public class ActDraw extends Activity implements OnTouchListener {
>
> >    float x = 200;
> >    float y = 200;
> >    float x1 = 10;
> >    float y1 = 45;
> >    float prvx = 150;
> >    float prvy = 150;
> >    MyView m;
>
> >   �...@override
> >    public void onCreate(Bundle savedInstanceState) {
> >        super.onCreate(savedInstanceState);
>
> >        m = new MyView(this);
> >        m.setOnTouchListener(this);
> >        setContentView(m);
>
> >    }
> >    public boolean onTouch(View v, MotionEvent event) {
> >        switch (event.getAction()) {
> >        case MotionEvent.ACTION_DOWN: {
> >            prvx = x;
> >            prvy = y;
> >            x = event.getX();
> >            y = event.getY();
> >             m.invalidate();
> >        }
> >        }
> >        return false;
> >    }
>
> >    class MyView extends View {
> >        Paint p = new Paint();
> >        Bitmap bm;
> >        int i;
>
> >        public MyView(Context context) {
> >            super(context);
>
> >        }
>
> >       �...@override
> >        protected void onDraw(Canvas canvas) {
> >            super.onDraw(canvas);
> >            p.setColor(Color.GREEN);
> >            p.setStrokeWidth(4);
> >            canvas.drawLine(prvx, prvy, x, y, p);
> >         }
> >    }
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: How to draw directly on screen without calling invalidate?

2009-05-05 Thread Sukitha Udugamasooriya

Thanks. Is there a way to save the Canvas object on re-draw that in
the onDraw()??
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: How to draw directly on screen without calling invalidate?

2009-05-05 Thread Mariano Kamp
The onDraw() method starts from the scratch every time and so doesn't keep
your drawings from the last invocation. Instead you would need to save all
the previous points yourself and use them in onDraw().

On Tue, May 5, 2009 at 9:25 AM, Sukitha Udugamasooriya wrote:

>
> I want to draw strokes on my screen when the user touches. Next stroke
> should be drawn from the end point
> of the previous stroke.
> This is my code. What happens here is just only the current stroke is
> drawn. Previous strokes are vanished? What is wrong here? Please
> help..
>
> package src.test;
>
> import android.app.Activity;
> import android.content.Context;
> import android.graphics.Bitmap;
> import android.graphics.Canvas;
> import android.graphics.Color;
> import android.graphics.Paint;
> import android.os.Bundle;
> import android.view.MotionEvent;
> import android.view.View;
> import android.view.View.OnTouchListener;
>
> public class ActDraw extends Activity implements OnTouchListener {
>
>float x = 200;
>float y = 200;
>float x1 = 10;
>float y1 = 45;
>float prvx = 150;
>float prvy = 150;
>MyView m;
>
>@Override
>public void onCreate(Bundle savedInstanceState) {
>super.onCreate(savedInstanceState);
>
>m = new MyView(this);
>m.setOnTouchListener(this);
>setContentView(m);
>
>}
>public boolean onTouch(View v, MotionEvent event) {
>switch (event.getAction()) {
>case MotionEvent.ACTION_DOWN: {
>prvx = x;
>prvy = y;
>x = event.getX();
>y = event.getY();
> m.invalidate();
>}
>}
>return false;
>}
>
>class MyView extends View {
>Paint p = new Paint();
>Bitmap bm;
>int i;
>
>public MyView(Context context) {
>super(context);
>
>}
>
>@Override
>protected void onDraw(Canvas canvas) {
>super.onDraw(canvas);
>p.setColor(Color.GREEN);
>p.setStrokeWidth(4);
>canvas.drawLine(prvx, prvy, x, y, p);
> }
>}
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: How to draw directly on screen without calling invalidate?

2009-05-05 Thread Sukitha Udugamasooriya

I want to draw strokes on my screen when the user touches. Next stroke
should be drawn from the end point
of the previous stroke.
This is my code. What happens here is just only the current stroke is
drawn. Previous strokes are vanished? What is wrong here? Please
help..

package src.test;

import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;

public class ActDraw extends Activity implements OnTouchListener {

float x = 200;
float y = 200;
float x1 = 10;
float y1 = 45;
float prvx = 150;
float prvy = 150;
MyView m;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

m = new MyView(this);
m.setOnTouchListener(this);
setContentView(m);

}
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN: {
prvx = x;
prvy = y;
x = event.getX();
y = event.getY();
 m.invalidate();
}
}
return false;
}

class MyView extends View {
Paint p = new Paint();
Bitmap bm;
int i;

public MyView(Context context) {
super(context);

}

@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
p.setColor(Color.GREEN);
p.setStrokeWidth(4);
canvas.drawLine(prvx, prvy, x, y, p);
}
}
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: How to draw directly on screen without calling invalidate?

2009-05-04 Thread Romain Guy

You can't :)

On Sun, May 3, 2009 at 11:57 PM, Sukitha Udugamasooriya
 wrote:
>
> Hello,
>
> I'm also facing this problem. I'm relatively new to Android.
>
> Have you found the solution??
>
> >
>



-- 
Romain Guy
Android framework engineer
romain...@android.com

Note: please don't send private questions to me, as I don't have time
to provide private support.  All such questions should be posted on
public forums, where I and others can see and answer them

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: How to draw directly on screen without calling invalidate?

2009-05-04 Thread Sukitha Udugamasooriya

Hello,

I'm also facing this problem. I'm relatively new to Android.

Have you found the solution??

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: How to draw directly on screen without calling invalidate?

2009-04-01 Thread Dianne Hackborn
This is one of the things SurfaceView is for.  For a regular view hierarchy
you can't draw outside of updates, period.

I don't know what you mean by clearing the screen with black.  We don't do
that.  Within your window, if the window is translucent, we will clear the
update region back to translucent before drawing the view hierarchy just so
that the drawing will be correct.  Unfortunately there isn't a way right now
to say that a particular view is opaque so the hierarchy can skip drawing of
its parents if the update region is only within that view.

On Wed, Apr 1, 2009 at 12:01 PM, Tomei Ningen wrote:

> I need to animate at a very fast rate (without using OpenGL). Now I am
> calling View.invalidate() to paint to the screen, but this has the effect of
>
> A: clearing the screen with black
> B: drawing the content view
> C: drawing the child view (which occupies only part of the screen, and is
> the only thing that's animating)
>
> How can I avoid doing A and B at every frame? I am looking for
>
>  Canvas c = getWindow().getCanvas();
>  c.drawSomething();
>  c.doneDrawing();
>
> If this is not possible, can I at least get rid of A?
>
> Thanks
>
>
>
> >
>


-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support.  All such questions should be posted on public
forums, where I and others can see and answer them.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---