我自身工程里面,创建一个空的activity,在对应的xml里面添加我自定义的CircleImageView,把activity的入口改为新建空activity,保证没有走任何业务逻辑。依然出现卡顿现象
本工程所用到的框架,我直接现在框架官方demo下来将CircleImageView加入,运行很流畅
MotionEvent.ACTION_MOVE 事件进行onDraw
@Override
protected void onDraw(Canvas canvas) {
centerX = getWidth() / 2;
centerY = getHeight() / 2;
canvas.rotate(mDirection, getWidth() / 2, getHeight() / 2);
super.onDraw(canvas);
}
@Override
public boolean onTouchEvent(MotionEvent event) {
float curAngle = getAngle(event.getX(), event.getY());
mGestureDetector.onTouchEvent(event);
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
stopAnimation();
break;
case MotionEvent.ACTION_MOVE:
updateRotation(centerX - event.getX(), centerY - event.getY());
break;
case MotionEvent.ACTION_UP:
break;
}
return true;
}
private void updateRotation(float newX, float newY) {
int degree = (int) Math.toDegrees(Math.atan2(newY, newX)) - 90;
this.mDirection = degree;
this.invalidate();
}
苦思冥想不得其解,还请各路高手们帮忙看看问题可能会出现在哪里