I am animating a view which has list view inside it through drawing. i.e setting the height from 0 to particular height.when list-view is empty my view draws smoothly.but when list-view is populated my view animates very slowly.
here is my animation code
public static void expand(final View v) {
v.measure(MeasureSpec.makeMeasureSpec(android.view.ViewGroup.LayoutParams.MATCH_PARENT,
MeasureSpec.EXACTLY),
MeasureSpec.makeMeasureSpec(500, MeasureSpec.EXACTLY));
final int targtetHeight = v.getMeasuredHeight();
v.getLayoutParams().height = 0;
v.setVisibility(View.VISIBLE);
Animation a = new Animation()
{
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
v.getLayoutParams().height = interpolatedTime == 1
? 500
: (int)(targtetHeight * interpolatedTime);
v.requestLayout();
}
@Override
public boolean willChangeBounds() {
return true;
}
};
// 1dp/ms
a.setDuration(500);
v.startAnimation(a);
}
here is my xml.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/recent_view"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:visibility="gone"
android:background="#FF0000"
android:layout_marginTop="130px"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
>
<ListView
android:id="@+id/callslist_history"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/top"
android:layout_alignLeft="@+id/top"
android:layout_alignRight="@+id/top"
/>
</RelativeLayout>
initial height of my view is 0dp then on expand i animate its height to 500dp.but this animation works smoothly only when list-view is not populated.