title: Cannot remove Padding from Tabs when using Custom views with Tab Layout
body: <p>I have added a Relative Layout in Custom View and have added this in Tab Layout. I am using a white background for tabs and have not applied any padding in tabs custom layout. But then also I am getting padding on tabs  due to which I am shown some grey background within tabs as if android is internally applying padding to tabs. I am trying to display three text views which I am able to do but one of them is truncating because of padding applied to tabs. Also I want to have consistent background color for tabs.</p>
  <p>Here is my code:</p>
  <p><strong>activity_home.xml:</strong></p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;android.support.design.widget.CoordinatorLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
      xmlns:tools=&quot;http://schemas.android.com/tools&quot;
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;match_parent&quot;
      android:fitsSystemWindows=&quot;true&quot;
      tools:context=&quot;com.customtablayoutapplication.HomeActivity&quot;&gt;
  
      &lt;android.support.design.widget.AppBarLayout
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:theme=&quot;@style/AppTheme.AppBarOverlay&quot;&gt;
  
          &lt;android.support.v7.widget.Toolbar
              android:id=&quot;@+id/toolbar&quot;
              android:layout_width=&quot;match_parent&quot;
              android:layout_height=&quot;?attr/actionBarSize&quot;
              android:background=&quot;?attr/colorPrimary&quot;
              app:popupTheme=&quot;@style/AppTheme.PopupOverlay&quot; /&gt;
  
  
      &lt;/android.support.design.widget.AppBarLayout&gt;
  
      &lt;include layout=&quot;@layout/content_home&quot; /&gt;
  
  
  &lt;/android.support.design.widget.CoordinatorLayout&gt;
  </code></pre>
  <p><strong>fragment_home.xml:</strong></p>
  <pre><code>&lt;LinearLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
      xmlns:tools=&quot;http://schemas.android.com/tools&quot;
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;match_parent&quot;
      android:orientation=&quot;vertical&quot;
      android:theme=&quot;@style/AppTheme.AppBarOverlay&quot;
      tools:context=&quot;com.customtablayoutapplication.HomeFragment&quot;
      tools:showIn=&quot;@layout/activity_home&quot;&gt;
  
      &lt;android.support.design.widget.TabLayout
          android:id=&quot;@+id/tabs&quot;
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;wrap_content&quot;
          app:tabGravity=&quot;fill&quot;
          app:tabMode=&quot;fixed&quot; /&gt;
  
      &lt;android.support.v4.view.ViewPager
          android:id=&quot;@+id/viewpager&quot;
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;match_parent&quot;
          app:layout_behavior=&quot;@string/appbar_scrolling_view_behavior&quot; /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  <p><strong>custom_tab.xml:</strong></p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;RelativeLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
      android:layout_width=&quot;match_parent&quot;
      android:background=&quot;@android:color/white&quot;
      android:layout_height=&quot;match_parent&quot;
      android:layout_gravity=&quot;center&quot;&gt;
  
      &lt;TextView
          android:id=&quot;@+id/total_request_count&quot;
          android:layout_width=&quot;wrap_content&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:layout_alignParentBottom=&quot;true&quot;
          android:layout_alignParentRight=&quot;true&quot;
          android:text=&quot;12&quot;
          android:textAllCaps=&quot;false&quot;
          android:visibility=&quot;gone&quot;
          android:textColor=&quot;@color/colorPrimaryDark&quot;
          android:textSize=&quot;12sp&quot; /&gt;
  
  
      &lt;RelativeLayout
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;match_parent&quot;
          android:layout_centerVertical=&quot;true&quot;
          android:fitsSystemWindows=&quot;true&quot;
          android:gravity=&quot;center&quot;&gt;
  
          &lt;TextView
              android:id=&quot;@+id/request_status&quot;
              android:layout_width=&quot;match_parent&quot;
              android:layout_height=&quot;match_parent&quot;
              android:gravity=&quot;center&quot;
              android:text=&quot;New Request&quot;
              android:textAllCaps=&quot;false&quot;
              android:textColor=&quot;@color/colorPrimaryDark&quot;
              android:textSize=&quot;12sp&quot; /&gt;
  
          &lt;TextView
              android:id=&quot;@+id/badge_icon&quot;
              android:layout_width=&quot;13dp&quot;
              android:layout_height=&quot;13dp&quot;
              android:layout_alignParentRight=&quot;true&quot;
              android:layout_alignTop=&quot;@id/request_status&quot;
              android:layout_marginLeft=&quot;-3dp&quot;
              android:layout_marginTop=&quot;15dp&quot;
              android:background=&quot;@drawable/circular_text_background&quot;
              android:clickable=&quot;false&quot;
              android:visibility=&quot;gone&quot; /&gt;
      &lt;/RelativeLayout&gt;
  
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  <p><strong>HomeFragment.java:</strong></p>
  <pre><code>package com.customtablayoutapplication;
  
  import android.os.Bundle;
  import android.support.design.widget.TabLayout;
  import android.support.v4.app.Fragment;
  import android.support.v4.app.FragmentManager;
  import android.support.v4.app.FragmentPagerAdapter;
  import android.support.v4.view.ViewPager;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.RelativeLayout;
  import android.widget.TextView;
  
  import java.util.ArrayList;
  import java.util.List;
  
  /**
   * A placeholder fragment containing a simple view.
   */
  public class HomeFragment extends Fragment {
  
      private ViewPager viewPager;
      private TabLayout tabLayout;
  
      public HomeFragment() {
      }
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
      }
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
                               Bundle savedInstanceState) {
          
          View view = inflater.inflate(R.layout.fragment_home, container, false);
          viewPager = (ViewPager) view.findViewById(R.id.viewpager);
          setupViewPager(viewPager);
  
          tabLayout = (TabLayout) view.findViewById(R.id.tabs);
          tabLayout.setupWithViewPager(viewPager);
          setUpTabIcons();
          return view;
      }
  
      private void setUpTabIcons() {
          RelativeLayout tabNewRequest= (RelativeLayout) LayoutInflater.from(getActivity()).inflate(R.layout.custom_tab, null);
          TextView tabNewRequesttxt = (TextView) tabNewRequest.findViewById(R.id.request_status);
          tabNewRequesttxt.setText(&quot;New Request&quot;);
          tabLayout.getTabAt(0).setCustomView(tabNewRequest);
  
          RelativeLayout tabInProgress= (RelativeLayout) LayoutInflater.from(getActivity()).inflate(R.layout.custom_tab, null);
          TextView tabInProgresstxt = (TextView) tabInProgress.findViewById(R.id.request_status);
          tabInProgresstxt.setText(&quot;In Progress&quot;);
          tabLayout.getTabAt(1).setCustomView(tabInProgress);
  
          RelativeLayout tabWorkDone= (RelativeLayout) LayoutInflater.from(getActivity()).inflate(R.layout.custom_tab, null);
          TextView tabWorkDonetxt = (TextView) tabWorkDone.findViewById(R.id.request_status);
          tabWorkDonetxt.setText(&quot;Work Done&quot;);
          tabLayout.getTabAt(2).setCustomView(tabWorkDone);
  
          RelativeLayout tabDelivered= (RelativeLayout) LayoutInflater.from(getActivity()).inflate(R.layout.custom_tab, null);
          TextView tabDeliveredtxt = (TextView) tabDelivered.findViewById(R.id.request_status);
          tabDeliveredtxt.setText(&quot;Delivered&quot;);
          tabLayout.getTabAt(3).setCustomView(tabDelivered);
      }
  
      private void setupViewPager(ViewPager viewPager) {
          ViewPagerAdapter adapter = new ViewPagerAdapter(getChildFragmentManager());
          adapter.addFragment(new NewRequestFragment(), &quot;New Request&quot;);
          adapter.addFragment(new InProgressFragment(), &quot;In Progress&quot;);
          adapter.addFragment(new WorkDoneFragment(), &quot;Work Done&quot;);
          adapter.addFragment(new DeliveredFragment(), &quot;Delivered&quot;);
          viewPager.setAdapter(adapter);
      }
  
      class ViewPagerAdapter extends FragmentPagerAdapter {
          private final List&lt;Fragment&gt; mFragmentList = new ArrayList&lt;&gt;();
          private final List&lt;String&gt; mFragmentTitleList = new ArrayList&lt;&gt;();
  
          public ViewPagerAdapter(FragmentManager manager) {
              super(manager);
          }
  
          @Override
          public Fragment getItem(int position) {
              return mFragmentList.get(position);
          }
  
          @Override
          public int getCount() {
              return mFragmentList.size();
          }
  
          public void addFragment(Fragment fragment, String title) {
              mFragmentList.add(fragment);
              mFragmentTitleList.add(title);
          }
  
          @Override
          public CharSequence getPageTitle(int position) {
              return mFragmentTitleList.get(position);
          }
      }
  }
  </code></pre>
  <p>Fixed Tab are having grey background arround white background:</p>
  <p><img src="https://i.stack.imgur.com/Zqx1U.png" alt="screenshot" /></p>