ListView with custom ImageView
<p>I have a problem that is being bugging me for almost 3 days. I have a ListView with a Custom Array Adapter. Everything pretty standard. Then, in the layout, I have a Custom ImageView. I think there is a problem with the Custom ImageView because on scroll the image disappear.</p>

<p>I made a little test and add a rectangle onDraw() method and it always show. I have also add a normal ImageView and it always shows as well.</p>

<p>The problem is with the Custom View that sometimes show the image and other don't.</p>

<p>Here is some code</p>

<p><strong>Custom View</strong></p>

<pre><code> public class CropTopImageView extends ImageView {
        private static Paint paint;

        public CropTopImageView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init();
    }

    public CropTopImageView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        init();
    }

    public CropTopImageView(Context context) {
        super(context);
        init();
    }

    private void init(){
        setScaleType(ScaleType.MATRIX);
          paint = new Paint();
          paint.setStrokeWidth(20);
          paint.setColor(Color.RED);
          paint.setStyle(Paint.Style.STROKE);
    }

    @Override
    protected boolean setFrame(int l, int t, int r, int b) {

        Matrix matrix = getImageMatrix();
        float scale;
        int viewWidth = getWidth() - getPaddingLeft() - getPaddingRight();
        int viewHeight = getHeight() - getPaddingTop() - getPaddingBottom();
        int drawableWidth = getDrawable().getIntrinsicWidth();
        int drawableHeight = getDrawable().getIntrinsicHeight();

        if (drawableWidth * viewHeight &gt; drawableHeight * viewWidth) {
            scale = (float) viewHeight / (float) drawableHeight;
        } else {
            scale = (float) viewWidth / (float) drawableWidth;
        }

        matrix.setScale(scale, scale);
        setImageMatrix(matrix);
        return super.setFrame(l, t, r, b);http://imageshack.us/a/img560/8381/example3g.png
    }

        // This is just a test
    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);

          int height = this.getMeasuredHeight();
          int width = this.getMeasuredWidth();

          // Draw a border
          canvas.drawRect(10, 10, width-10, height-10, paint);
    }
}
</code></pre>

<p><strong>Adapter getView</strong></p>

<pre><code>  @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        Log.d("CardView", "getView " + position + " " + convertView);
        ViewHolder holder = null;

        if (convertView == null) {

            convertView = (RelativeLayout) inflater.inflate(resource, null);
            holder = new ViewHolder();
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        holder.cardImage = (CropTopImageView) convertView
                .findViewById(R.id.cardImage);

        return convertView;
    }
</code></pre>

<p>XML Layout</p>

<pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="30dip"
    android:orientation="vertical"
    android:paddingTop="30dp"
&gt;

    &lt;com.td.fs.android.customview.CropTopImageView
        android:id="@+id/cardImage"
        android:layout_width="246dp"
        android:layout_height="70dip"
        android:layout_centerHorizontal="true"
        android:layout_gravity="center"
         android:src="@drawable/card_visa_blue"
     /&gt;

    &lt;com.td.fs.android.customview.CropTopImageView
        android:id="@+id/pocketImage"
        android:layout_width="275dp"
        android:layout_height="30dp"
        android:layout_centerHorizontal="true"
        android:layout_gravity="center"
        android:layout_marginTop="50dip"
        android:adjustViewBounds="true"
        android:cropToPadding="false"
        android:scaleType="fitXY"
        android:src="@drawable/holder_pocket" /&gt;

    &lt;ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/pocketImage"
        android:layout_alignParentTop="true"
        android:layout_marginLeft="92dp"
        android:src="@drawable/home_dashboard_picker" /&gt;

&lt;/RelativeLayout&gt;
</code></pre>

<p>ImageView is always showing. 
onDraw is always showing.
CropTopImageView src image shows the first time than randomly disappear/appear. </p>

<p>I don't know if I can show some images because it a project for a company.</p>

<p><strong>UPDATE</strong>
<img src="http://i.stack.imgur.com/sc91r.png" alt="enter image description here">
<img src="http://i.stack.imgur.com/NWaa4.png" alt="enter image description here">
<img src="http://i.stack.imgur.com/zS7hX.png" alt="enter image description here"></p>
