title: Custom Tab layout with ViewPager2
body: <p>I am trying to use custom tabs for my <code>ViewPager2</code> via the <code>TabLayout.Tab.setCustomView</code> method. But it doesn't work.</p>
  <p>Here is a code snippet from my <code>Activity</code> for preparing the <code>ViewPager2</code> with a <code>TabLayout</code>:</p>
  <pre><code>@Override
  protected void onCreate(Bundle savedInstanceState)
  {
     ...
     
     mMyViewPager2 = findViewById(R.id.view_pager);
     mMyViewPager2.setAdapter(new MyPagerAdapter(this));
     mMyTabLayout = findViewById(R.id.media_tab);
     new TabLayoutMediator(mMyTabLayout, mMyViewPager2, myTabHandler).attach();
  }
  
  private class MyPagerAdapter extends FragmentStateAdapter
  {
     ...
  }
  </code></pre>
  <p>And here is the code snippet for my <code>TabLayoutMediator.TabConfigurationStrategy</code> (also inside my <code>Activity</code>):</p>
  <pre><code>private TabLayoutMediator.TabConfigurationStrategy myTabHandler = new TabLayoutMediator.TabConfigurationStrategy()  
  {
      private TextView tabTitle;
      private TextView tabSubtitle;
  
      @Override
      public void onConfigureTab(@NonNull TabLayout.Tab tab, int position)
      {
          View tabView = LayoutInflater.from(MyActivity.this).inflate(R.layout.tab_layout, null, false);
  
          tabTitle    = tabView.findViewById(R.id.tab_title);
          tabSubtitle = tabView.findViewById(R.id.tab_subtitle);
          
          tabTitle.setText(&quot;Title&quot; + (position + 1));
          tabSubtitle.setText(&quot;Subtitle&quot; + (position + 1));
  
          tab.setCustomView(tabView);
      }
  }
  </code></pre>
  <p>But with the above setup, the tabs remain blank.</p>
  <p>I've also tried the following approach in my <code>TabConfigurationStrategy</code> (from <a href="https://stackoverflow.com/questions/61148494/style-specific-tab-using-tablayout-and-viewpager2">this post</a>); but it doesn't work, either:</p>
  <pre><code>FrameLayout frameLayout = new FrameLayout(MyActivity.this);
  frameLayout.addView(tabView);
  </code></pre>
  <p>I'd like to know what is wrong with my code, and how can I correct it to show custom tab layouts with <code>ViewPager2</code>.</p>