# Storyly Fragment Overlay
Storyly supports overlay fragments and this guide shows you how to show and dismiss fragment over Storyly.
Before you begin
You need to have the working Storyly integration as described in Initial SDK Setup
WARNING
Before you start, you need to be sure that context is FragmentActivity
to show fragment over Storyly. Otherwise, fragment will not show.
# Show fragment overlay Storyly
Showing fragment(s) over Storyly is quite straightforward. Once you create a Storyly instance and fragment instance, just send fragment to showExternalFragment
method as a parameter.
As a note, Storyly automatically pauses the story and shows the fragment over it.
class AnotherActivity: AppCompatActivity {
fun addFragment() {
// val storylyView = StorylyView(this)
// addView(storylyView)
val fragment = Fragment()
storylyView.showExternalFragment(fragment)
}
}
class AnotherActivity extends AppCompatActivity {
function void addFragment() {
//StorylyView storylyView = new StorylyView(this);
//addView(storylyView);
Fragment fragment = Fragment();
storylyView.showExternalFragment(fragment);
}
}
# Dismiss latest fragment
When you need to dismiss latest fragment, just call dismissLatestFragment
method. Storyly automatically resumes the story and dismisses the latest fragment.
class AnotherActivity: AppCompatActivity {
fun dismissLatestFragment() {
// val storylyView = StorylyView(this)
// addView(storylyView)
// val fragment = Fragment()
storylyView.dismissLatestFragment()
}
}
class AnotherActivity extends AppCompatActivity {
function void dismissLatestFragment() {
//StorylyView storylyView = new StorylyView(this);
//addView(storylyView);
// Fragment fragment = Fragment();
storylyView.dismissLatestFragment();
}
}
# Dismiss all fragment
When you need to dismiss all showned fragments, just call dismissAllFragments
method. Storyly automatically resumes the story and dismisses all fragments.
class AnotherActivity: AppCompatActivity {
fun dismissAllFragments() {
// val storylyView = StorylyView(this)
// addView(storylyView)
// val fragment = Fragment()
storylyView.dismissAllFragments()
}
}
class AnotherActivity extends AppCompatActivity {
function void dismissAllFragment() {
//StorylyView storylyView = new StorylyView(this);
//addView(storylyView);
// Fragment fragment = Fragment();
storylyView.dismissAllFragments();
}
}