Using ShoplivePreview
- Print
Using ShoplivePreview
- Print
Article summary
Did you find this summary helpful?
Thank you for your feedback
Implement the app’s live preview
You can directly implement the preview using the ShopLivePreview
provided by the Shoplive SDK .
activity.xml
// If only one of width or height is written, it is flexible.
<cloud.shoplive.sdk.ShopLivePreview
android:id="@+id/preview"
android:layout_width="something dimens"
android:layout_height="something dimens" />
preview.start(“{accessKey}”, “{campaignKey}”)
preview.setOnClickListener {
// Preview transition animation
ShopLive.setPreviewTransitionAnimation(requireActivity(), binding.preview)
ShopLive.play(requireActivity(), campaignKey)
preview.release()
}
// For lifecycle observing preview
preview.setLifecycleObserver(this.viewLifecycleOwner)
Control swipe gesture
You can exit the preview by swiping using the ShopLiveSwipePreview
. The usage is the same as ShopLivePreview
.
<cloud.shoplive.sdk.ShopLiveSwipePreview
android:id="@+id/swipePreview"
android:layout_width="something dimens"
android:layout_height="something dimens" />
swipePreview.start(“{accessKey}”, “{campaignKey}”)
swipePreview.setOnPreviewClickListener {
// Preview transition animation
ShopLive.setPreviewTransitionAnimation(requireActivity(), binding.preview)
ShopLive.play(requireActivity(), campaignKey)
swipePreview.release()
}
// For lifecycle observing preview
swipePreview.setLifecycleObserver(this.viewLifecycleOwner)