【发布时间】:2017-05-26 05:02:28
【问题描述】:
我想在向右滑动时旋转一个瓶子。它在 lollipop 中运行良好,但在 marshmallow 中运行不顺畅。图片大小100*100。
请告诉我错误以及如何解决它。
以下是我的代码:
GestureDetector.OnGestureListener listener = new GestureDetector.SimpleOnGestureListener() {
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
// clearAnimation();
int sanctity = 50;
//
Speed = Math.round(velocityX / 1000);
if ((e2.getX() - e1.getX()) > sanctity) {
swipeLayout.setVisibility(View.GONE);
scroller.fling(0, 0, (int) Math.hypot(velocityX, velocityY), 0, 0, Integer.MAX_VALUE, 0, 0);
invalidate();
}
return true;
}
};
@Override
public void computeScroll() {
if (scroller.computeScrollOffset()) {
firstime = false;
float current = scroller.getCurrX();
Log.d("computeScroll ", String.valueOf(current));
setRotation(current * FACTOR);
invalidate();
}
}
【问题讨论】:
标签: android android-5.0-lollipop android-6.0-marshmallow image-rotation android-5.1.1-lollipop