1.TabLayout 添加分割线以及设置分割线高度
LinearLayout linearLayout = (LinearLayout) mTabLayout.getChildAt(0)
linearLayout.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE)
linearLayout.setDividerDrawable(getResources().getDrawable(R.drawable.layout_divider_vertical))
linearLayout.setDividerPadding(FontDisplayUtil.dip2px(this,12))
2.获取到tabLayout中tab的view
getTabAt()获取到的tab对象并不是目标view,下面的代码通过反射获取目标View
public View getTabView(int index){
View tabView = null;
TabLayout.Tab tab = mTab.getTabAt(index);
Field view = null;
try {
view = TabLayout.Tab.class.getDeclaredField("mView");
} catch (NoSuchFieldException e) {
e.printStackTrace();
}
view.setAccessible(true);
try {
tabView = (View) view.get(tab);
} catch (IllegalAccessException e) {
e.printStackTrace();
}
return tabView;
}