how to avoid postinvalidate() redraw the whole screen

Put your problem here if it does not fit any of the other categories.

how to avoid postinvalidate() redraw the whole screen

Postby battlecry18 » Thu Apr 24, 2008 9:12 am

I want make an effect,
first I call postInvalidate(), I draw a Rect with width = 200 and height = 200,
then i make width = width/2,and height = height /2, and recall postInvalidate
I want a samll Rect(w=100,h=100) draw on a big Rect(w=200,h=200)
but the System redraw the whole screen, the big Rect disappear
is anybody know how to draw a image without redraw a whole screen?
i already try clipRect(); But it seems useless
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2.         protected void onDraw(Canvas canvas) {
  3.  
  4.                 count++;
  5.  
  6.                 if(count <= 5){
  7.  
  8.                         width = width/2;
  9.  
  10.                         height = height /2;
  11.  
  12.                 }else{
  13.  
  14.                         width = 200;
  15.  
  16.                         height = 200;
  17.  
  18.                         count = 0;
  19.  
  20.                 }
  21.  
  22.                 int color = Math.abs(rand.nextInt());
  23.  
  24.                 mPaint.setColor(color |0xff000000);
  25.  
  26.                 canvas.drawRect(0, 0, width, height, mPaint);
  27.  
  28.         }
  29.  
  30.  
Parsed in 0.032 seconds, using GeSHi 1.0.8.4



THX for all your help :D
battlecry18
Once Poster
Once Poster
 
Posts: 1
Joined: Sun Apr 20, 2008 2:33 am
Location: china

Top

Postby plusminus » Fri May 16, 2008 11:26 am

Hello battlecry,

Api-Documentation wrote:void android.view.View.invalidate(Rect dirty)

public void invalidate(Rect dirty)
Mark the the area defined by dirty as needing to be drawn. If the view is visible, onDraw(Canvas) will be called at some point in the future. This must be called from a UI thread. To call from a non-UI thread, call postInvalidate(). WARNING: This method is destructive to dirty.

Parameters
dirty the rectangle representing the bounds of the dirty region


Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 16 guests