MarginPageTransformer

class MarginPageTransformer : ViewPager2.PageTransformer
kotlin.Any
   ↳ androidx.viewpager2.widget.MarginPageTransformer

Adds space between pages via the ViewPager2.PageTransformer API.

Internally relies on View#setTranslationX and View#setTranslationY.

Note: translations on pages are not reset when this adapter is changed for another one, so you might want to set them manually to 0 when dynamically switching to another transformer, or when switching ViewPager2 orientation.

Summary

Public constructors

<init>(@Px marginPx: Int)

Creates a MarginPageTransformer.

Public methods

Unit
transformPage(@NonNull page: View, position: Float)

Public constructors

<init>

MarginPageTransformer(@Px marginPx: Int)

Creates a MarginPageTransformer.

Parameters
marginPx Int: non-negative margin

Public methods

transformPage

fun transformPage(@NonNull page: View, position: Float): Unit