仿京東商城下拉刷新RefreshListView,下拉的時候小人跑步加載效果,
本項目來自:https://github.com/nugongshou110/JingDongRefreshListView
主要由以下代碼繪畫的:
/**
* 繪製方法
* @param canvas
*/
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
//因爲包裹和快遞小哥要分別來畫,因此使用save和restore方法
//save
//畫包裹
//restore
//save
//畫小哥
//restore
canvas.save();
canvas.scale(mCurrentProgress, mCurrentProgress , measuredWidth-scaledGoods.getWidth()/2 , measuredHeight/2);
mPaint.setAlpha(mCurrentAlpha);
canvas.drawBitmap(scaledGoods, measuredWidth-scaledGoods.getWidth(), measuredHeight/2-scaledGoods.getHeight()/2, mPaint);
canvas.restore();
canvas.save();
canvas.scale(mCurrentProgress, mCurrentProgress , 0 , measuredHeight/2);
mPaint.setAlpha(mCurrentAlpha);
canvas.drawBitmap(scaledPeople, 0,0,mPaint);
canvas.restore();
}git
項目來源《IT藍豹》:www.itlanbao.com
github