获取tabLayout中的子tab的对应view
2018-08-06 本文已影响0人
啤酒小龙虾
// index 索引值
public ViewgetTabView(int index) {
View tabView =null;
TabLayout.Tab tab =tabLayout.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;
}