Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I move and change fragment view size
    text
    copied!<p>I have an activity with two fragments like this image : <a href="http://img96.imageshack.us/img96/1083/astatus.png" rel="nofollow noreferrer">status A</a> Fragment B is a ListFragment. When user clicks on one row in fragment B. I have show detail. And the UI should like this: <a href="http://img338.imageshack.us/img338/1984/bstatus.png" rel="nofollow noreferrer">status B</a></p> <p>How can I move and resize fragment B?</p> <p>I tried this way but don't know whether it is a correct way or hacky way. I set this layout for the activity.</p> <pre><code>&lt;LinearLayout android:id="@+id/linearLayoutMainPart" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_above="@+id/scrollViewBottomMenu" android:layout_toRightOf="@+id/scrollViewLeftMenu" android:background="@android:color/white" android:orientation="horizontal" &gt; &lt;FrameLayout android:id="@+id/leftContainer" android:layout_width="wrap_content" android:layout_height="match_parent" &gt; &lt;/FrameLayout&gt; &lt;FrameLayout android:id="@+id/rightContainer" android:layout_width="0dip" android:layout_height="match_parent"&gt; &lt;/FrameLayout&gt; &lt;/LinearLayout&gt; </code></pre> <p>I create 3 fragment A, B, C class. When the activity create I add two fragment A, B to leftContainer and rightContainer. (fragment A layout width is fixed). When user click on one row in fragment B. I replace fragment A by another instance of fragment B (with different layout, and using the same data with the old fragment B instance). And replace fragment B in rightContainer by an instance of fragment C.</p> <p>In fragment B class. I have flag to choose layout when onCreateView method is called, something like : </p> <pre><code>if(rightPosition) return B_right_pos_layout; else return B_left_pos_layout; </code></pre> <p>I think I can use the same instance of Fragment B. By doing like this :</p> <pre><code> FragmentB fragmentB = (FragmentB) getSupportFragmentManager().findFragmentByTag(FRAGMENT_B_TAG); fragmentB.setRightPos(false); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.replace(rightContainer, fragmentC); transaction.replace(leftContainer, fragmentB); transaction.commit(); </code></pre> <p>I think this way is more like a hack way. What is the best way?</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