title: RecyclerView with unknown/variable row layouts
body: <p>Since RecyclerView uses ViewHolders, it means that you must have a predefined layout for each row. But what if each row needs to have a variable amount of views displayed?</p>
  
  <p>For example, say I'm creating an instant messaging application where users can attach pictures to messages. They could attach anywhere from 0 to x pictures. When you create a RecyclerView to display these pictures (that are downloaded from a server), how would you make the rows include the correct number of ImageViews to display them?</p>
  
  <p>There's a few ways I can think of doing this, but none really seem like good options.</p>
  
  <ol>
  <li>Create ImageViews in onBindViewHolder, add them to a layout in the ViewHolder. (Isn't this what the ViewHolder tries to prevent? This would probably be laggy, especially with lots of pictures)</li>
  <li>Restrict the amount of pictures the user can attach to a message to x, then add x ImageViews to the layout that are set to invisible/gone. In onBindViewHolder, set the ImageViews to display the picture and set these ImageViews visible. (What if I allow pictures &amp; videos to be attached? Do I then need to add x ImageViews and x VideoViews as well?)</li>
  <li>Put a GridView in each RecyclerView item and populate the GridView
  inside onBindViewHolder. (I assume this would have no benefit over
  option #1 because it's pretty much the same thing?)</li>
  </ol>
  
  <p>That's all I can think of. Is there any other option that is designed for this sort of situation that I have not come across? Or what are the typical approaches taken towards this problem?</p>