title: TabLayout Icon not showing
body: <p>I'm trying to make tab with tablayout following this <a href="https://guides.codepath.com/android/Google-Play-Style-Tabs-using-TabLayout#add-custom-view-to-tablayout" rel="nofollow noreferrer">https://guides.codepath.com/android/Google-Play-Style-Tabs-using-TabLayout#add-custom-view-to-tablayout</a></p>
  <p>Now I'm trying to show icon instead of text using the imagespan. But without luck, can anyone help point out what is missing from this tutorial?</p>
  <p>Here's the code</p>
  <pre><code>public class HomeActivity extends FragmentActivity {
  
  //Fragments List
  public ArrayList &lt;Fragment&gt; fragmentList;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_home);
  
      setUpFragmentList();
  
      // Get the ViewPager and set it's PagerAdapter so that it can display items
      ViewPager viewPager = (ViewPager) findViewById(R.id.home_viewpager);
      viewPager.setAdapter(new HomeFragmentPagerAdapter(getSupportFragmentManager(), HomeActivity.this, fragmentList));
  
      // Give the TabLayout the ViewPager
      TabLayout tabLayout = (TabLayout) findViewById(R.id.sliding_tabs);
      //start this 2 are to set the tab to fill entire screen
      tabLayout.setTabMode(TabLayout.MODE_FIXED);
      tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
      //end this 2 are to set the tab to fill entire screen
  
      tabLayout.setupWithViewPager(viewPager);
      tabLayout.getTabAt(1).setIcon(R.drawable.ic_tab_down_activity);
  
  }
  
  private void setUpFragmentList() {
      fragmentList = new ArrayList&lt;&gt;();
  
      fragmentList.add(new MyActivitesFragment());
      fragmentList.add(new ChatListFragment());
      fragmentList.add(new QuickMatchFragment());
      fragmentList.add(new FilterMatchFragment());
  }
  }
  
  
  public class HomeFragmentPagerAdapter extends FragmentPagerAdapter {
  private String tabTitles[] = new String[] { &quot;Tab1&quot;, &quot;Tab2&quot;, &quot;Tab3&quot; ,&quot;Tab4&quot;};
  private Context context;
  
  private ArrayList &lt;Fragment&gt; fragmentList;
  
  private int[] imageResId = {
          // unclicked
          R.drawable.ic_tab_down_activity,
          R.drawable.ic_tab_down_chat,
          R.drawable.ic_tab_down_find,
          R.drawable.ic_tab_down_filter
  };
  
  public HomeFragmentPagerAdapter(FragmentManager fm, Context context, ArrayList &lt;Fragment&gt; fragmentList) {
      super(fm);
      this.context = context;
      this.fragmentList = fragmentList;
  }
  
  @Override
  public int getCount() {
      return fragmentList.size();
  }
  
  @Override
  public Fragment getItem(int position) {
      return fragmentList.get(position);
  }
  
  @Override
  public CharSequence getPageTitle(int position) {
  
      Drawable image = context.getResources().getDrawable(imageResId[position]);
      image.setBounds(0, 0, image.getIntrinsicWidth(), image.getIntrinsicHeight());
      SpannableString sb = new SpannableString(&quot; &quot;);
      ImageSpan imageSpan = new ImageSpan(image, ImageSpan.ALIGN_BOTTOM);
      sb.setSpan(imageSpan, 0, 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
      return sb;
  }
  }
  </code></pre>