Skip to content

Instantly share code, notes, and snippets.

@gabornovakp
Created February 7, 2017 14:18
Show Gist options
  • Save gabornovakp/675b45b0101779d1209ae72a62010438 to your computer and use it in GitHub Desktop.
Save gabornovakp/675b45b0101779d1209ae72a62010438 to your computer and use it in GitHub Desktop.
Fragments on top of each other
<android.support.design.widget.CoordinatorLayout
android:id="@+id/activity_container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!--This will be the one we'll cover-->
<FrameLayout
android:id="@+id/list_fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<!--This is the top one. If it's there we don't see the list_container-->
<FrameLayout
android:id="@+id/detail_fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</android.support.design.widget.CoordinatorLayout>
//...
//In the Activity, you just add the bott
private void addListFragment() {
getSupportFragmentManager().beginTransaction()
.replace(R.id.list_fragment_container, ShareLinkListFragment.newInstance(preziOid, preziTitle), ShareLinkListFragment.TAG)
.commit();
showList();
}
public void showDetailFragment() {
//A bit simplified code...
Fragment detailFragment = DetailFragment.newInstance(preziOid, preziTitle, constructRevealSettings());
getActivity().getSupportFragmentManager().beginTransaction()
.replace(R.id.detail_fragment_container, fragment, DetailFragment.TAG)
.commit();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment