'''
private void updateTabTextView(TabLayout.Tab tab, boolean isSelect) {
if (isSelect) {
try {
java.lang.reflect.Field fieldView= tab.getClass().getDeclaredField("mView");
fieldView.setAccessible(true);
View view= (View) fieldView.get(tab);
java.lang.reflect.Field fieldTxt= view.getClass().getDeclaredField("mTextView");
fieldTxt.setAccessible(true);
TextView tabSelect= (TextView) fieldTxt.get(view);
tabSelect.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
tabSelect.setText(tab.getText());
} catch (Exception e) {
e.printStackTrace();
}
} else {
try {
java.lang.reflect.Field fieldView= tab.getClass().getDeclaredField("mView");
fieldView.setAccessible(true);
View view= (View) fieldView.get(tab);
java.lang.reflect.Field fieldTxt= view.getClass().getDeclaredField("mTextView");
fieldTxt.setAccessible(true);
TextView tabSelect= (TextView) fieldTxt.get(view);
tabSelect.setTypeface(Typeface.defaultFromStyle(Typeface.NORMAL));
tabSelect.setText(tab.getText());
} catch (Exception e) {
e.printStackTrace();
}
}
}
'''
网友评论