标签:des style blog color os for
1、选中标题后,高亮标题
@Override public void onPageSelected(int position) { setSelectTextColor(position); if (delegatePageListener != null) { delegatePageListener.onPageSelected(position); } }
private void setSelectTextColor(int position) { for (int i = 0; i < tabCount; i++) { View view = tabsContainer.getChildAt(i); if (view instanceof ImageButton) { } else if (view instanceof RelativeLayout) { View viewText = ((RelativeLayout) view).getChildAt(0); TextView tabTextView = (TextView) viewText; if (viewText instanceof TextView) { if (position == i) { tabTextView.setTextColor(自定义颜色); } else { tabTextView.setTextColor(tabTextColor); } } } } }
2、首次进入默认第一个标题高亮,关键标红代码
private void updateTabStyles() { for (int i = 0; i < tabCount; i++) { View v = tabsContainer.getChildAt(i); v.setBackgroundResource(tabBackgroundResId); if (v instanceof RelativeLayout) { View v1 = ((RelativeLayout) v).getChildAt(0); if (v1 instanceof TextView) { TextView tab = (TextView) v1; tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize); tab.setTypeface(tabTypeface, tabTypefaceStyle); if (i == 0) { tab.setTextColor(自定义颜色); } else { tab.setTextColor(tabTextColor); } if (textAllCaps) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { tab.setAllCaps(true); } else { tab.setText(tab.getText().toString().toUpperCase(locale)); } } } } } }
PagerSlidingTabStrip 高亮选中标题,布布扣,bubuko.com
标签:des style blog color os for
原文地址:http://www.cnblogs.com/zgz345/p/3834138.html