title: Strange behavior with Android view.invalidate()
body: <p>I have 3 custom views placed vertically in a LinearLayout, they are used to display different dynamic info, so they're supposed be invalidated and redrawn at different time. But I found the view invalidation is out of usual expectation, that is: if you invalidate the top view,all  3 views are invalidated at the same time, if you invalidate the middle view, the middle and bottom views are invalidated, the top one is not, if you invalidate the bottom view, only the bottom view itself is invalidated, this is what I want, so what happened with the first 2 cases ? I searched and got similar questions like:</p>
  
  <p><a href="https://stackoverflow.com/questions/26192491/invalidate-one-view-force-other-views-invalidate-too-how-separating-that">https://stackoverflow.com/questions/26192491/invalidate-one-view-force-other-views-invalidate-too-how-separating-that</a></p>
  
  <p><a href="https://stackoverflow.com/questions/8120986/android-invalidate-only-single-view">Android Invalidate() only single view</a></p>
  
  <p>but it seems no exact answer. I post my code here, any comment is appreciated.</p>
  
  <hr>
  
  <p><i>TestView.java</i></p>
  
  <pre><code>package com.vrb.myview;
  
  import android.app.Activity;
  import android.os.Bundle;
  import android.view.View;
  
  
  public class TestView extends Activity {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
      }
  
      public void onTest(View view){
          MyView1 mv1 = (MyView1)findViewById(R.id.mv1);
          MyView1 mv2 = (MyView1)findViewById(R.id.mv2);
          MyView1 mv3 = (MyView1)findViewById(R.id.mv3);
  
          mv1.invalidate(); // all 3 views are invalidated
      //  mv2.invalidate(); // mv2 and mv3 are invalidated
      //  mv3.invalidate(); // only mv3 is invalidated,this is what I want
      }
  }
  </code></pre>
  
  <p><i>MyView1.java</i></p>
  
  <pre><code>package com.vrb.myview;
  
  import java.util.Random;
  
  import android.content.Context;
  import android.graphics.Canvas;
  import android.graphics.Color;
  import android.graphics.Paint;
  import android.graphics.Rect;
  import android.util.AttributeSet;
  import android.util.Log;
  import android.view.View;
  
  public class MyView1 extends View {
      Rect rc=null;
      Paint p=null;
      Random r;
      public MyView1(Context ctx){
          super(ctx);
          rc = new Rect();
          p = new Paint();
          r = new Random();
      }
      public MyView1(Context ctx, AttributeSet set){
          super(ctx, set);
          rc = new Rect();
          p = new Paint();
          r = new Random();
      }
  
      public void onDraw(Canvas canvas){
          if(canvas.getClipBounds(rc)){
              Log.d("MyView1","id="+getId()+" Rect: "+rc.left+","+rc.top+","+rc.right+","+rc.bottom);
              p.setColor(Color.argb(0xff, Math.abs(r.nextInt())%255, Math.abs(r.nextInt())%255, Math.abs(r.nextInt())%255));
              canvas.drawRect(rc, p);
          }else{
              Log.d("MyView1","id="+getId()+" Rect=null");        
          }       
      }
  }
  </code></pre>
  
  <p><i>main.xml</i></p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:id="@+id/root"
      android:orientation="vertical"
      tools:context="com.vrb.myview.TestView" &gt;
  
      &lt;com.vrb.myview.MyView1
          android:layout_width="match_parent"
          android:layout_height="100px"
          android:id="@+id/mv1" /&gt;
  
      &lt;com.vrb.myview.MyView1
          android:layout_width="match_parent"
          android:layout_height="100px"
          android:id="@+id/mv2" /&gt;
  
      &lt;com.vrb.myview.MyView1
          android:layout_width="match_parent"
          android:layout_height="100px"
          android:id="@+id/mv3" /&gt;
  
      &lt;Button
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_gravity="center"
          android:text="Invalidate"
          android:onClick="onTest"
          android:id="@+id/btn" /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>