-
-
Save BonusTrack02/aed704c6c989a9345444758894c7acff to your computer and use it in GitHub Desktop.
ViewPager2 set page margin including dp to px convert
This file contains 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
binding.viewPager2.setPageTransformer(MarginPageTransformer(dpToPx(8).toInt())) | |
private fun dpToPx(dp: Int): Float { | |
val density = context.resources.displayMetrics.density | |
return round(dp * density) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment