Overview of Onboarding
masterViewPager combined with a custom transformer that utilizes callbacks to manage scene transitions.repository·master·Indexed 23 days ago
https://github.com/eoinfogarty/onboardingAn Android library for creating visually engaging user introduction flows using a ViewPager and custom transformers. It provides the BaseSceneFragment class and SceneChangeListener interface to manage scene transitions and UI states as users navigate through onboarding pages.
ViewPager combined with a custom transformer that utilizes callbacks to manage scene transitions.To create custom onboarding transitions, you must implement the SceneChangeListener interface. This interface provides callbacks that allow you to react as a scene enters, centers, or exits the viewport, or when it is no longer in view. This is typically implemented within a Fragment to manage the UI state of each onboarding page.
public interface SceneChangeListener {
void enterScene(@Nullable ImageView sharedElement, float position);
void centerScene(@Nullable ImageView sharedElement);
void exitScene(@Nullable ImageView sharedElement, float position);
void notInScene();
}The library provides BaseSceneFragment, an abstract class that implements SceneTransformer.SceneChangeListener. To use it, extend this class and override the lifecycle methods (enterScene, centerScene, exitScene, and notInScene).
Important: You must set a position tag on the root layout of every scene fragment so the transformer can identify which fragment to trigger callbacks for. Use the setRootPositionTag(@NonNull View root) method provided by the base class to do this.
public abstract class BaseSceneFragment extends Fragment
implements SceneTransformer.SceneChangeListener {
protected static final String KEY_POSITION = "KEY_POSITION";
// we have to set a position tag to the root layout of every scene fragment
// this is so the transformer will know who to make a callback to
protected void setRootPositionTag(@NonNull View root) {
root.setTag(getArguments().getInt(KEY_POSITION));
}
@Override
public abstract void enterScene(@Nullable ImageView sharedElement, float position);
@Override
public abstract void centerScene(@Nullable ImageView sharedElement);
@Override
public abstract void exitScene(@Nullable ImageView sharedElement, float position);
@Override
public abstract void notInScene();
...
}