title: Android : TabLayout not responding to clicks
body: <p>I have just created a layout that has a DrawerLayout and inside this there is the toolbar, tablayout and viewpager. However the in the tablayout, the tabs are not responding on clicking on them, but is changing on swiping. Here is the code:</p>
  
  <pre><code>&lt;android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  android:id="@+id/drawer"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:fitsSystemWindows="true"
  tools:context=".activities.HomeActivity"&gt;
  
  &lt;LinearLayout
      android:id="@+id/main_layout"
      xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_height="match_parent"
      android:layout_width="match_parent"
      android:orientation="vertical"&gt;
      &lt;!-- Content for screen without action bar--&gt;
  
      &lt;android.support.v7.widget.Toolbar
          android:id="@+id/toolbar"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_alignParentTop="true"
          android:background="@color/theme_color"
          android:elevation="6dp"
          android:minHeight="?attr/actionBarSize"
          android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
          app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/&gt;
  
      &lt;FrameLayout
          android:id="@+id/frame"
          android:layout_width="match_parent"
          android:layout_height="match_parent"&gt;
  
          &lt;android.support.design.widget.TabLayout
              android:id="@+id/tab_layout"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_below="@+id/toolbar"
              android:background="@color/theme_color"
              android:elevation="6dp"
              android:minHeight="?attr/actionBarSize"
              app:tabIndicatorColor="@color/sub_theme_color"
              android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"/&gt;
  
          &lt;View
              android:layout_width="match_parent"
              android:layout_height="4dp"
              android:background="@drawable/toolbar_shadow" /&gt;
  
          &lt;android.support.v4.view.ViewPager
              android:id="@+id/pager"
              android:layout_width="match_parent"
              android:layout_height="fill_parent"
              android:layout_below="@id/tab_layout"/&gt;
  
      &lt;/FrameLayout&gt;
  
  
  &lt;/LinearLayout&gt;
  
  &lt;android.support.design.widget.NavigationView
      android:id="@+id/navigation_view"
      android:layout_height="match_parent"
      android:layout_width="wrap_content"
      android:layout_gravity="start"
      app:headerLayout="@layout/header_navigation_drawer"
      app:menu="@menu/menu_drawer_links"
      /&gt;
  </code></pre>
  
  <p></p>
  
  <p>And in MainActivity.java</p>
  
  <pre><code>private Toolbar toolbar;
  private NavigationView navigationView;
  private DrawerLayout drawerLayout;
  
  // Initializing Toolbar and setting it as the actionbar
      toolbar = (Toolbar) findViewById(R.id.toolbar);
      setSupportActionBar(toolbar);
  
      //Intializing tab-layout and viewpager for tabs
      TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout);
      tabLayout.addTab(tabLayout.newTab().setText("Tasks"));
      tabLayout.addTab(tabLayout.newTab().setText("Updates"));
      tabLayout.addTab(tabLayout.newTab().setText("Redeem"));
      tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
  
      // Initializing viewpager to hold the tab-layout
      final ViewPager viewPager = (ViewPager) findViewById(R.id.pager);
      final PagerAdapter adapter = new PagerAdapter
              (getSupportFragmentManager(), tabLayout.getTabCount());
      viewPager.setAdapter(adapter);
      viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
  
  
      tabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
          @Override
          public void onTabSelected(TabLayout.Tab tab) {
              viewPager.setCurrentItem(tab.getPosition());
          }
  
          @Override
          public void onTabUnselected(TabLayout.Tab tab) {
  
          }
  
          @Override
          public void onTabReselected(TabLayout.Tab tab) {
  
          }
      });
  </code></pre>
  
  <p>Now here is the weird part: It is clickable in Lollipop, but is not working in pre-lollipop version. </p>