Android 带有缩放动画的ListView不是';t平滑
当列表只有一行,只有一个文本视图时,它会被平滑地设置动画,当列表开始变重时,问题就开始了。当我加载更多行时,每一行都包含一个ImageView 我使用了我自己的动画,尽管我尝试了使用XML的更简单的方法,但效果并没有更好 这是动画:Android 带有缩放动画的ListView不是';t平滑,android,android-listview,android-animation,Android,Android Listview,Android Animation,当列表只有一行,只有一个文本视图时,它会被平滑地设置动画,当列表开始变重时,问题就开始了。当我加载更多行时,每一行都包含一个ImageView 我使用了我自己的动画,尽管我尝试了使用XML的更简单的方法,但效果并没有更好 这是动画: public Animation slidePaneAnim2 (final Context context, final View view, final int maxHeight, final boole
public Animation slidePaneAnim2 (final Context context,
final View view,
final int maxHeight,
final boolean openORclose ){
/** Create new Slide Pane animation */
Animation anim = new Animation() {
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
int newHeight;
int initHeight=200;
if (openORclose) {
//In case we want to open pane
newHeight = initHeight + (int) (maxHeight * interpolatedTime);
} else {
//In case we want to close pane
newHeight = initHeight + (int) (maxHeight * (1-interpolatedTime));
}
//Apply new params
view.getLayoutParams().height = newHeight;
view.requestLayout();
}
...
};
return anim;
}
有人知道如何使其更平滑吗?问题在于您的
动画
,您正在applyTransform
中调用requestLayout
,这对性能非常不利。使用NineoldRoid动画库,您将看到不同之处。它类似于内置的新动画框架,但也支持较旧的Android版本。谢谢M-WaJeEh,这是一个很棒的图书馆,像魔术一样工作!