title: How to disable invalidate()?
body: <p>At first my programm looks like this:</p>
  
  <p><img src="https://i.stack.imgur.com/UzNlO.jpg" alt="enter image description here"></p>
  
  <p>But when i am moving the picture around the screen programm turns to:</p>
  
  <p><img src="https://i.stack.imgur.com/YmNKF.jpg" alt="enter image description here"></p>
  
  <p>Red graph is random-generated in onDraw method. So i want to draging picture around and have static background that not inavalidates while im moving picture.</p>
  
  <p>here is my code:
  <strong>Custom View:</strong>
      package com.graph.base;</p>
  
  <pre><code>import android.content.Context;
  import android.graphics.Canvas;
  import android.graphics.Color;
  import android.graphics.Paint;
  import android.graphics.Path;
  import android.util.AttributeSet;
  import android.view.View;
  import java.util.Random;
  
  public class CustomView extends View
  {
  Random random=new Random();
  public CustomView(Context context, AttributeSet attrs, int defStyle) {
      super(context, attrs, defStyle);
  }
  
  public CustomView(Context context, AttributeSet attrs) {
      super(context, attrs);
  }
  
  public CustomView(Context context) {
      super(context);
  }
  public void onDraw (Canvas canvas)
  {
      super.onDraw(canvas);
      Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
      paint.setStyle(Paint.Style.FILL);
      paint.setColor(Color.WHITE);
      canvas.drawPaint(paint);
      Path path=new Path();
      path.moveTo(10, 10);
      for (float i=0.5f; i&lt;=140; i+=10)
      {
          path.quadTo(10+i*5, 10+random.nextInt(500), 10+(i+10)*5,     10+random.nextInt(500));
      }
      paint.setDither(true);
      paint.setColor(Color.RED);
      paint.setStyle(Paint.Style.STROKE);    
      paint.setStrokeJoin(Paint.Join.ROUND);
      paint.setStrokeCap(Paint.Cap.ROUND);
      paint.setStrokeWidth(2);
      canvas.drawPath(path, paint);
  }
  </code></pre>
  
  <p>}</p>
  
  <p><strong>MainActivity</strong></p>
  
  <pre><code>package com.graph.base;
  
  import android.app.Activity;
  import android.os.Bundle;
  import android.util.Log;
  import android.view.MotionEvent;
  import android.view.View;
  import android.widget.FrameLayout;
  import android.widget.ImageView;
  
  public class MainActivity extends Activity {
  FrameLayout frame;
  ImageView image;
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
      frame=(FrameLayout)findViewById(R.id.frameLayout1);
      image=(ImageView)findViewById(R.id.imageView1);
      image.setOnTouchListener(new View.OnTouchListener() {
  
          public boolean onTouch(View v, MotionEvent event) {
              Log.e("TAG", "Touch happend");
              switch (event.getAction())
              {
              case MotionEvent.ACTION_MOVE:
              {
                  image.setPadding((int)event.getX(),     (int)event.getY(), 0, 0);
                  break;
              }
  
              }
  
              return true;
          }
      });
  }
  
  public void invalidateButton_Click (View v)
  {
      frame.invalidate();
  }
  }
  </code></pre>