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?
}
API example: