title: Display many views efficiently in a FlexboxLayout
body: <p>My goal is to efficiently display a lot of TextViews (with background) in a FlexboxLayout (or something similar).</p>
  
  <p>I want to display information about actors and crew members from a movie in a kind of 'tag'-layout style</p>
  
  <p><a href="https://i.stack.imgur.com/PTfuf.png" rel="nofollow noreferrer">How the layout looks like (one of the FlexboxLayouts is marked)</a></p>
  
  <p>I inflate the TextViews <strong>dynamically</strong> via LayoutInflater into a FlexboxLayout. The <strong>problem</strong> is of course that with <strong>a lot of data (which means a lot of views</strong>, sometimes 30 or more in over 20 Flexbox-Layouts) the creation time of my fragment/activity increases and the <strong>activtiy takes longer to open</strong>.</p>
  
  <p>The TextView I inflate:</p>
  
  <pre><code>&lt;TextView 
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/tag_name"
        android:layout_width="wrap_content"
        android:layout_height="30dp"
        android:layout_margin="5dp"
        android:paddingStart="10dp"
        android:paddingEnd="10dp"
        android:gravity="center_vertical"
        android:background="@drawable/bg_tag"
        android:textColor="?android:textColorSecondary"
        android:text="@string/placeholder" /&gt;
  </code></pre>
  
  <p>My container layout (TextViews get inflated into the FlexboxLayout <code>@+id/fxl_names</code>):</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"&gt;
  
    &lt;TextView
      android:id="@+id/txt_names"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:textColor="?attr/colorOnBackground"
      android:padding="5dp"
      android:textSize="16sp"
      android:textStyle="bold"
      android:text="test" /&gt;
  
    //TextViews get inflated into this FlexboxLayout
  
    &lt;com.google.android.flexbox.FlexboxLayout
      android:id="@+id/fxl_names"
      app:flexWrap="wrap"
      android:animateLayoutChanges="true"
      android:layout_width="match_parent"
      android:layout_height="wrap_content" /&gt;
  
    &lt;com.google.android.material.button.MaterialButton
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:id="@+id/view_more"
      android:visibility="gone"
      android:layout_margin="0dp"
      android:text="Show all"
      style="@style/Widget.MaterialComponents.Button.TextButton.Dialog" /&gt;
  
  &lt;/LinearLayout&gt;
  
  </code></pre>
  
  <p>Thank you for any help/advice on optimizing this layout!</p>