Last active
August 28, 2019 18:11
-
-
Save sk8darr/23e469f5e17ec9e9eded2e88c6432f57 to your computer and use it in GitHub Desktop.
Page transformer effect inspired https://share.protopie.io/j2Fusg5L7dg?_ga=2.111323524.1201599279.1565893576-381682164.1565893576
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.view.View | |
import androidx.appcompat.widget.AppCompatImageView | |
import androidx.viewpager2.widget.ViewPager2 | |
class PageTransformer : ViewPager2.PageTransformer { | |
override fun transformPage(view: View, position: Float) { | |
when { | |
position <= 1 -> { | |
//Replace R.id.image for your view id | |
val image = view.findViewById<AppCompatImageView>(R.id.image) | |
image.rotation = position * 40F | |
view.alpha = 1F | |
view.pivotY = view.height * 0.5f | |
view.rotationY = 13f * position | |
} | |
else -> { | |
view.alpha = 0F | |
} | |
} | |
} | |
} |
Author
sk8darr
commented
Aug 28, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment