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 layou
I solved this by setting the margin & padding of your custom view's parent to zero, when adding new tabs to tab layout.
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
lp.setMargins(0,0,0,0);
TabLayout.Tab newTab = mTabsBottom.newTab().setCustomView(R.layout.view_custom_tab);
setupTabParentLayout(newTab.getCustomView(), lp);
..
..
..
private void setupTabParentLayout(View customView, LinearLayout.LayoutParams lp) {
LinearLayout tabParent = (LinearLayout) customView.getParent();
tabParent.setLayoutParams(lp);
tabParent.setPadding(0,0,0,0);
}
Trick here was to use LinearLayout.LayoutParams for custom view's parent.