Skip to content

Instantly share code, notes, and snippets.

@basarik
Created November 30, 2018 17:43
Show Gist options
  • Save basarik/8845466489f5e627d13c963122cd3326 to your computer and use it in GitHub Desktop.
Save basarik/8845466489f5e627d13c963122cd3326 to your computer and use it in GitHub Desktop.
recycleview two columns and if list size is one, show row as a one column, othervise two columns
//documents -> list of recycleview
val layoutManager = GridLayoutManager(activity, 2)
layoutManager.spanSizeLookup = object : GridLayoutManager.SpanSizeLookup() {
override fun getSpanSize(position: Int): Int {
return if (documents.size > 1) 1 else 2
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment