我的应用程序中有一个小动画,其结尾会更改ListView的位置参数:listArr.layout(0, (int) (actionBar.getHeight() + filterTabHeight),
listArr.getWidth(), (int) (actionBar.getHeight() + listArr.getHeight() + filterTabHeight));
即。它设置得比开始时低一点(它以全屏开始,按下按钮后,它向下滑动一点,以显示屏幕顶部的下方)。
按下列表,我可以看到它的参数确实发生了变化,而且它的位置也确实发生了变化。现在,如果SlidingDrawer在此时打开,布局将重新排列,并且列表将在其上打开全屏。
为什么会这样?
private void setFilterAnimationAnimation(boolean isOpenAnimation) {
TranslateAnimation verticalAnimation;
float scale = context.getResources().getDisplayMetrics().density;
filterTabHeight = FILTER_HEIGHT_IN_DP * scale;
if (isOpenAnimation) {
listArr.layout(0, (int) (actionBar.getHeight() + filterTabHeight),
listArr.getWidth(), (int) (actionBar.getHeight() + listArr.getHeight() + filterTabHeight));
verticalAnimation = new TranslateAnimation(0, 0, -filterTabHeight, 0);
} else {
listArr.layout(0, (int) (actionBar.getHeight()),
listArr.getWidth(), (int) (actionBar.getHeight() + listArr.getHeight()));
verticalAnimation = new TranslateAnimation(0, 0, filterTabHeight, 0);
}
verticalAnimation.setInterpolator(new AccelerateDecelerateInterpolator());
verticalAnimation.setDuration(250);
animSet = new AnimationSet(false);
animSet.cancel();
animSet.reset();
animSet.setFillAfter(true);
animSet.addAnimation(verticalAnimation);
isTabOpen = !isTabOpen;
listArr.startAnimation(animSet);
}
这是xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res/com.softtechnics.something"
android:id="@+id/coupon_list_layout"
style="@style/FillParent"
android:orientation="vertical" >
<include
android:id="@+id/filter_tab"
android:layout_width="match_parent"
android:layout_height="34dp"
android:layout_below="@+id/action_bar"
layout="@layout/filter" />
<com.softtechnics.something.gui.components.ListArr
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/action_bar" />
<com.softtechnics.something.gui.components.ActionBar
android:id="@+id/action_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true" />
<ProgressBar
android:id="@+id/progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:visibility="gone" />
<com.softtechnics.something.gui.components.Footer
android:id="@+id/drawer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" />
<ImageView
android:id="@+id/imageView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@id/action_bar"
android:scaleType="fitXY"
android:src="@drawable/head_bar_shadow" />
页脚是我的SlidingDrawer。谢谢!