Note that there are some explanatory texts on larger screens.

plurals
  1. POFragments keep going back to the default position when MapView is Zoomed In/Out
    text
    copied!<p>I have an activity with 3 fragments displayed, a <code>MapActivity</code>, a <code>ListActivity</code>, and a (normal) <code>DetailsActivity</code>. The <code>ListActivity</code> and <code>DetailsActivity</code> is placed over the MapActivity.</p> <p>There's a function to hide both ListActivity and DetailsActivity with an Animation, and <code>onAnimationEnd()</code> I set a new layout for the hidden Activity.</p> <p>The problem I'm facing is, everytime one of the ListActivity or DetailsActivity hidden <strong>(picture State 2)</strong>, and then I pinch the screen on the MapActivity to zoom the map, it always goes back to the default view <strong>(picture State 1)</strong>. The closed Activities are automatically opened again.</p> <p>Does anybody know how to prevent the hidden fragments from going to the first state again when I pinch the MapActivity?</p> <p>this is an example of the function how I hide the DetailsActivity():</p> <pre><code>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()); } }; </code></pre> <p>Here's the xml layout:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;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" &gt; &lt;fragment android:id="@+id/my_map_fragment1" android:name="com.wwh.fragments.MyMapFragment" android:layout_width="fill_parent" android:layout_height="fill_parent" &gt; &lt;!-- Preview: layout=@layout/my_map_fragment --&gt; &lt;/fragment&gt; &lt;RelativeLayout android:id="@+id/fragment_layout" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="55dp" android:orientation="horizontal" &gt; &lt;LinearLayout android:id="@+id/detail_layout" android:layout_width="wrap_content" android:layout_height="fill_parent" android:orientation="horizontal" &gt; &lt;fragment android:id="@+id/my_detail_fragment" android:name="com.wwh.fragments.DetailFragment" android:layout_width="380dp" android:layout_height="fill_parent" /&gt; &lt;LinearLayout android:id="@+id/border_detail" android:layout_width="1dp" android:layout_height="fill_parent" android:background="@drawable/border" android:orientation="vertical" /&gt; &lt;/LinearLayout&gt; &lt;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" &gt; &lt;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" /&gt; &lt;LinearLayout android:id="@+id/border_list" android:layout_width="1dp" android:layout_height="fill_parent" android:background="@drawable/border" android:orientation="vertical" /&gt; &lt;ImageView android:id="@+id/shadow_vertical" android:layout_width="2dp" android:layout_height="fill_parent" android:layout_marginTop="53dp" android:background="@drawable/shadow_vertical" /&gt; &lt;/LinearLayout&gt; &lt;/RelativeLayout&gt; &lt;/RelativeLayout&gt; </code></pre> <p><img src="https://i.stack.imgur.com/GSwa1.png" alt="The normal default state, all fragments are opened"></p> <p><img src="https://i.stack.imgur.com/jV2XR.png" alt="Second state, fragments are closed"></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload