-1
我創建了打開/關閉和生長/在同一時間收縮滑動抽屜動畫。我使用ValueAnimator和AnimatorUpdateListener內部操作視圖的邊距來增加或減少(增大/縮小)它的大小。同時,ValueAnimator正在處理開啓和關閉。對於Galaxy Mega 2手機,這個動畫非常不穩定;不光滑。所有其他新舊手機似乎都能正常工作。有什麼辦法可以解決這個問題嗎?動畫滯後只在銀河兆豐2個手機
// close drawer
ValueAnimator animator = ValueAnimator.ofInt(0, 100);
animator.setInterpolator(new AccelerateInterpolator());
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
float ratio = ((Integer) animation.getAnimatedValue()/100);
// moves the drawer to the left and reduces its size by changing its margins
mDrawerParams.setMargins((int) (mLeftMargin * ratio), (Integer) animation.getAnimatedValue(),
0, (Integer) animation.getAnimatedValue());
rlDrawer.setLayoutParams(mDrawerParams);
}
這裏是我怎麼打開我的抽屜裏
// open drawer
ValueAnimator animator = ValueAnimator.ofInt(100, 0);
animator.setInterpolator(new AccelerateInterpolator());
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
float ratio = ((Integer) animation.getAnimatedValue()/100);
// moves the drawer to the right and increases its size by changing its margins
mDrawerParams.setMargins((int) (mLeftMargin * ratio), (Integer) animation.getAnimatedValue(),
0, (Integer) animation.getAnimatedValue());
rlDrawer.setLayoutParams(mDrawerParams);
}