Code example for Canvas

Methods: clipRect, restoreToCount, save, translate

0
 
    @Override 
    protected void dispatchDraw(Canvas canvas) {
        super.dispatchDraw(canvas);
        if (mAdapter == null || !mShouldPin || mCurrentHeader == null) return;
        int saveCount = canvas.save();
        canvas.translate(0, mHeaderOffset);
        canvas.clipRect(0, 0, getWidth(), mCurrentHeader.getMeasuredHeight()); // needed
        // for 
        // < 
        // HONEYCOMB 
        mCurrentHeader.draw(canvas);
        canvas.restoreToCount(saveCount);
    } 
 
    @Override 
    public void setOnScrollListener(OnScrollListener l) {
        mOnScrollListener = l;
    } 
 
    public void setOnItemClickListener(PinnedHeaderListView.OnItemClickListener listener) {