I have a small animation in my app and in that, the end of it changes the location parameters of a ListView:listArr.layout(0, (int) (actionBar.getHeight() + filterTabHeight),
listArr.getWidth(), (int) (actionBar.getHeight() + listArr.getHeight() + filterTabHeight));
i.e. It sets a bit lower than when it started (It starts as full screen and after a button press, its sliding down a little to reveal something beneath it on the top of the screen).
By pressing on the list I can see that it's parameters really changed and it's location also really changed. Now, if the SlidingDrawer is getting opened at that point, the layout gets rearranged and the list sets back to full screen on its on.
Why is that so?
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);
}
and this is the 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" />
Footer is my SlidingDrawer. Thanks!
layout method does not apply permanent changes to views. So next time when your layout gets updated all goes back. change listView's LayoutParams to apply permanent changes and read this.