The onDraw () 'method will be called twice when invalidate is called. I want to move the view up in onDraw() , here is my code
package com.blsm.sss.view; public class MoveRelativeLayout extends RelativeLayout { private int mDelta = 0; public MoveRelativeLayout(Context context, AttributeSet attrs) { super(context, attrs); } public MoveRelativeLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } public void move(int delta) { mDelta = delta; invalidate(); Logger.d("MoveRelativeLayout", "move() delta:" + mDelta); } @Override protected void onDraw(Canvas canvas) { Logger.d("MoveRelativeLayout", "onDraw() delta:" + mDelta); super.onDraw(canvas); canvas.translate(0, mDelta); } }
But when I call the ' move() ' onDraw , it is called twice. I donβt know why, can anyone help me?
source share