Present onboardings in Android SDK
Before you start, ensure that:
- You have installed Adapty Android SDK 3.8.0 or later.
- You have created an onboarding.
- You have added the onboarding to a placement.
If you've customized an onboarding using the Onboarding Builder, you don't need to worry about rendering it in your mobile app code to display it to the user. Such an onboarding contains both what should be shown and how it should be shown.
In order to display the visual onboarding on the device screen, you must first configure it. To do this, call the method AdaptyUI.getOnboardingView()
or create the OnboardingView
directly:
- Kotlin (option 1)
- Kotlin (option 2)
- Java (option 1)
- Java (option 2)
- XML
val onboardingView = AdaptyUI.getOnboardingView(
activity = this,
viewConfig = onboardingConfig,
eventListener = eventListener
)
val onboardingView = AdaptyOnboardingView(activity)
onboardingView.show(
viewConfig = onboardingConfig,
delegate = eventListener
)
AdaptyOnboardingView onboardingView = AdaptyUI.getOnboardingView(
activity,
onboardingConfig,
eventListener
);
AdaptyOnboardingView onboardingView = new AdaptyOnboardingView(activity);
onboardingView.show(onboardingConfig, eventListener);
<com.adapty.ui.onboardings.AdaptyOnboardingView
android:id="@+id/onboardingView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
After the view has been successfully created, you can add it to the view hierarchy and display it on the device screen.
Request parameters:
Parameter | Presence | Description |
---|---|---|
viewConfig | required | The onboarding configuration obtained from AdaptyUI.getOnboardingConfiguration() |
eventListener | required | An implementation of AdaptyOnboardingEventListener to handle onboarding events. Refer to Handling onboarding events for more details. |
Change loading indicator color
You can override the default color of the loading indicator in the following way:
<!--your theme -->
<style name="AppTheme" parent="android:Theme.Material.Light.NoActionBar">
<!--other attrs -->
<item name="adapty_progressIndicatorColor">@color/yourColor</item>
</style>
Add smooth transitions between the splash screen and onboarding
By default, between the splash screen and onboarding, you will see the loading screen until the onboarding is fully loaded. However, if you want to make the transition smoother, you can customize it and either extend the splash screen or display something else.
To do this, create adapty_onboarding_placeholder_view.xml
in res/layout
and define a placeholder (what exactly will be shown while the onboarding is being loaded) there.
If you define a placeholder, the onboarding will be loaded in the background and automatically displayed once ready.
Disable safe area paddings
By default, the onboarding view automatically applies safe area paddings to avoid system UI elements like status bar and navigation bar. However, if you want to disable this behavior and have full control over the layout, you can do so by setting the safeAreaPaddings
parameter to false
.
- Kotlin (option 1)
- Kotlin (option 2)
- Java (option 1)
- Java (option 2)
val onboardingView = AdaptyUI.getOnboardingView(
activity = this,
viewConfig = onboardingConfig,
eventListener = eventListener,
safeAreaPaddings = false
)
val onboardingView = AdaptyOnboardingView(activity)
onboardingView.show(
viewConfig = onboardingConfig,
delegate = eventListener,
safeAreaPaddings = false
)
AdaptyOnboardingView onboardingView = AdaptyUI.getOnboardingView(
activity,
onboardingConfig,
eventListener,
false
);
AdaptyOnboardingView onboardingView = new AdaptyOnboardingView(activity);
onboardingView.show(onboardingConfig, eventListener, false);
Alternatively, you can control this behavior globally by adding a boolean resource to your app:
<!-- res/values/bools.xml -->
<resources>
<bool name="adapty_onboarding_enable_safe_area_paddings">false</bool>
</resources>
When safeAreaPaddings
is set to false
, the onboarding will extend to the full screen without any automatic padding adjustments, giving you complete control over the layout and allowing the onboarding content to use the entire screen space.