I have an activity with 3 fragments displayed, a MapActivity, a ListActivity, and a (normal) DetailsActivity. The ListActivity and DetailsActivity is placed over the MapActivity.
There’s a function to hide both ListActivity and DetailsActivity with an Animation, and onAnimationEnd() I set a new layout for the hidden Activity.
The problem I’m facing is, everytime one of the ListActivity or DetailsActivity hidden (picture State 2), and then I pinch the screen on the MapActivity to zoom the map, it always goes back to the default view (picture State 1). The closed Activities are automatically opened again.
Does anybody know how to prevent the hidden fragments from going to the first state again when I pinch the MapActivity?
this is an example of the function how I hide the DetailsActivity():
public void hideDetailview() {
final Animation close = AnimationUtils.loadAnimation(this, R.anim.close);
close.setFillEnabled(true);
close.setAnimationListener(closeDetailAnimationListener);
fragment_detail.startAnimation(close);
Toast.makeText(MainFragmentActivity.this,WWHApplication.getDrawer(), Toast.LENGTH_SHORT).show();
}
private AnimationListener closeDetailAnimationListener = new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
int newLeft = -330;
fragment_detail.layout(newLeft,
fragment_detail.getTop(),
newLeft + fragment_detail.getMeasuredWidth(),
fragment_detail.getTop() + fragment_detail.getMeasuredHeight());
}
};
Here’s the xml layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res/com.wwh"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<fragment
android:id="@+id/my_map_fragment1"
android:name="com.wwh.fragments.MyMapFragment"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<!-- Preview: layout=@layout/my_map_fragment -->
</fragment>
<RelativeLayout
android:id="@+id/fragment_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="55dp"
android:orientation="horizontal" >
<LinearLayout
android:id="@+id/detail_layout"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<fragment
android:id="@+id/my_detail_fragment"
android:name="com.wwh.fragments.DetailFragment"
android:layout_width="380dp"
android:layout_height="fill_parent" />
<LinearLayout
android:id="@+id/border_detail"
android:layout_width="1dp"
android:layout_height="fill_parent"
android:background="@drawable/border"
android:orientation="vertical" />
</LinearLayout>
<LinearLayout
android:id="@+id/list_layout"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_toRightOf="@+id/detail_layout"
android:orientation="horizontal" >
<fragment
android:id="@+id/my_list_fragment"
android:name="com.wwh.fragments.MyListFragment"
android:layout_width="380dp"
android:layout_height="fill_parent"
android:background="@drawable/border"
android:shadowColor="#000000"
android:shadowDx="1.2"
android:shadowDy="12"
android:shadowRadius="12" />
<LinearLayout
android:id="@+id/border_list"
android:layout_width="1dp"
android:layout_height="fill_parent"
android:background="@drawable/border"
android:orientation="vertical" />
<ImageView
android:id="@+id/shadow_vertical"
android:layout_width="2dp"
android:layout_height="fill_parent"
android:layout_marginTop="53dp"
android:background="@drawable/shadow_vertical" />
</LinearLayout>
</RelativeLayout>
</RelativeLayout>


you’ve forgot to update the layout of the other fragments , perhaps?or maybe , you’ve got the wrong calculation of the new layout ?
i say this since animations on old android versions are tricky since they don’t really change the layout of the views . so maybe when animation ends , you actually touch on something that you don’t think you’re touching .
please provide more code . maybe it could help us understand why it occurs.
btw , please rename the fragments classes . they are not activities , so why have “activity” in their names?