Last active
March 17, 2021 04:20
-
-
Save OmarKRostom/0fac07b62a95a97760d17901e341ee08 to your computer and use it in GitHub Desktop.
Second step creating an arc layout manager
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
class ArcLayoutManager( | |
private val context: Context, | |
private var horizontalOffset: Int = 0 | |
) : RecyclerView.LayoutManager() { | |
override fun generateDefaultLayoutParams(): RecyclerView.LayoutParams = | |
RecyclerView.LayoutParams(MATCH_PARENT, WRAP_CONTENT) | |
override fun canScrollHorizontally(): Boolean = true | |
override fun scrollHorizontallyBy( | |
dx: Int, | |
recycler: RecyclerView.Recycler?, | |
state: RecyclerView.State? | |
): Int { | |
horizontalOffset += dx | |
return dx | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment