这是布局:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:cube_ptr="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/background">
<!-- Header -->
<customheader
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="@dimen/header_height" />
<!-- List-->
<se.emilsjolander.stickylistheaders.StickyListHeadersListView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animationCache="false"
android:scrollingCache="false"
android:layout_below="@+id/header" />
</RelativeLayout>
动画:
int headerHeight = getResources().getDimensionPixelSize(R.dimen.header_height);
Animation anim = new Animation() {
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mHeader.getLayoutParams();
params.setMargins(0, (int) (-headerHeight * interpolatedTime), 0, 0);
mHeader.setLayoutParams(params);
}
};
anim.setDuration(400);
mHeader.startAnimation(anim);
动画正在运行,标题的动画很流畅,但ListView(StickyHeader)非常滞后:(解决方法是什么?Thx
答案 0 :(得分:0)
我找到了解决方案:
...
getView().setY((int) (-headerHeight * interpolatedTime);
...
它就像一个魅力:)