I'm currently developing a content sharing app. At the moment, in the content-reader activity I have the main layout only (main content plus other views for the attachments, tags, and other info). It's a very complex layout wrapped in a ScrollView, with 300+ lines of XML code and one-time expensive operations (such as MarkDown retrieving and parsing). After that, I want to add a list of comments, which need to be put in a RecyclerView (I plan to add infinite scrolling as well).
However, I can't just put the RecyclerView after the main layout in the ScrollView, or else it will be always expanded and will always load all the elements.
From what I found online, my only choices appear to be to create a custom ViewHolder for the first element, wrapping the main layout, and to move the main layout in a fragment and inflate that for the first element (as described here, although it's considered a bad practice).
The first solution doesn't seem to be suitable because all of the parsing would have to be redone at every ViewHolder binding, and the second may be even worse because the entire fragment would have to be reinflated every time.
Is there a better solution to this problem?