rubensousa / DpadRecyclerView

A RecyclerView built for Android TV with Compose in mind and as a replacement for Leanback's BaseGridView.
https://rubensousa.github.io/DpadRecyclerView/
Apache License 2.0
136 stars 17 forks source link

Add support for custom parent alignment based on ViewHolder position #200

Closed rubensousa closed 2 months ago

rubensousa commented 8 months ago

API example:

val topAlignment = ParentAlignment(fraction = 0f)
recyclerView.setParentAlignmentOverride(object : ParentAlignmentOverride {
    override fun getAlignment(position: Int): ParentAlignment? {
        return if (position == 0) {
            // Align the first position to the top
            topAlignment
        } else {
            // Use default alignment configuration
            null
        }
    }
})
}

interface ParentAlignmentOverride {
    fun getAlignment(position: Int): ParentAlignment?
}