调用“ ”时,方法“ onDraw() ”将被调用两次invalidate
。我想将视图向上移动onDraw()
,这是我的代码
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);
}
}
但是当我调用方法时' move()
'onDraw
将被调用两次。我不知道为什么,有人可以帮助我吗?