0

Been trying to find the Android (in Kotlin) equivalent to the following iOS code (in Swift):

myViewController.collectionView.contentSize.height

Attempted the following, but it's yielding a value of 0 when I run it via the debugger:

recyclerView.height

Any suggestions or concepts I'm unaware of are welcomed.

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
Keith Kowalski
  • 115
  • 2
  • 11
  • 1
    Possible duplicate of [How to get the height of recyclerview 's item in "onBindViewHolder"](https://stackoverflow.com/questions/38764254/how-to-get-the-height-of-recyclerview-s-item-in-onbindviewholder) – Ramesh Prasad Nov 06 '18 at 00:17
  • Android works a bit differently. Look at the answer here https://stackoverflow.com/questions/38764254/how-to-get-the-height-of-recyclerview-s-item-in-onbindviewholder – Ramesh Prasad Nov 06 '18 at 00:18
  • I will look into these, thanks. – Keith Kowalski Nov 07 '18 at 05:53
  • I noticed the solutions here, though I have not thoroughly read over them, suggest possible ways to obtain the height of a recycler view item. I'm not after a specific item, but instead, the size of the recycler view once all the items have been added. This is doable in iOS, but I may need to find a work around solution for what I'm trying to do in Android, not sure yet! I imagine it would be possible to obtain the entire height by knowing the height of each item, then solving the overall height based on this, but I am not sure if this is correct. – Keith Kowalski Nov 07 '18 at 05:57

1 Answers1

-1

override fun getItemCount(): Int = itemList.size

EliodeBeirut
  • 74
  • 1
  • 13
  • This returns the size of my list / collection in the adapter class and is being used. What I'm after, is the size of the content height, in other words, the size of the view the user would see. I believe the other answers elude to what I'm after, it's definitely not a simple solution! – Keith Kowalski Nov 07 '18 at 05:52