Это странный. У меня есть анимация, которая переворачивает вид на 90 градусов, а затем другой вид поворачивается на другие 90 градусов, что позволяет сменить изображение. Это работает, и он хорошо работает на Samsung Tab 3; однако на вкладке 4 анимация очень рывкая. Если я включу «Профильный рендеринг GPU» - «Показать на экране в виде баров», анимация станет очень гладкой.Android Flip View Animation is Jerky
Я поместил отладочные журналы в анимацию, и я обнаружил, что функция applyTransformation называется тем же количеством раз, когда она рывкая и когда она гладкая. Поэтому все, что я могу сказать, это не обновить экран. Любые мысли были бы замечательными.
Вот анимация Flip. открытый класс AnimatedFlip extends Анимация { закрытый конечный поплавок mFromDegrees; закрытый окончательный поплавок mToDegrees; закрытый окончательный поплавок mCenterX; закрытый конечный поплавок mCenterY; частная камера mCamera;
public AnimatedFlip(float aFromDegrees, float aToDegrees, float aCenterX, float aCenterY)
{
mFromDegrees = aFromDegrees;
mToDegrees = aToDegrees;
mCenterX = aCenterX;
mCenterY = aCenterY;
}
@Override
public void initialize(int aWidth, int aHeight, int aParentWidth, int aParentHeight)
{
super.initialize(aWidth, aHeight, aParentWidth, aParentHeight);
mCamera = new Camera();
}
@Override
protected void applyTransformation(float aInterpolatedTime, Transformation aTransformation)
{
float degrees = mFromDegrees + ((mToDegrees - mFromDegrees) * aInterpolatedTime);
final Matrix matrix = aTransformation.getMatrix();
mCamera.save();
mCamera.rotateY(degrees);
mCamera.getMatrix(matrix);
mCamera.restore();
matrix.preTranslate(-mCenterX, -mCenterY);
matrix.postTranslate(mCenterX, mCenterY);
}
}
Анимация начинается с этого вызова.
mFlipStartingView.setVisibility(View.VISIBLE);
applyRotation(0, 90, mFlipStartingView);
Это функция, которая делает анимацию.
private void applyRotation(float aStart, float aEnd, final ImageView aView)
{
// Find the center of image
float centerX = aView.getWidth()/2.0f + aView.getX();
float centerY = aView.getHeight()/2.0f + aView.getY();
// Create a new 3D rotation with the supplied parameter
// The animation listener is used to trigger the next animation
final AnimatedFlip rotation = new AnimatedFlip(aStart, aEnd, centerX, centerY);
rotation.setDuration(mFlipAnimationTime);
rotation.setFillAfter(false);
rotation.setInterpolator(new LinearInterpolator());
rotation.setAnimationListener(new Animation.AnimationListener()
{
@Override public void onAnimationStart(Animation animation)
{
}
@Override public void onAnimationEnd(Animation animation)
{
if (aView != mFlipView)
{
mFlipStartingView.setVisibility(View.INVISIBLE);
mFlipView.setVisibility(View.VISIBLE);
applyRotation(-89, 0, mFlipView);
}
}
@Override public void onAnimationRepeat(Animation animation)
{
}
});
aView.startAnimation(rotation);
}
hii Мне нужен этот тип Rotate Animation –