Android基于ViewPager Fragment实现选项卡

2019-12-10 19:50:37王旭
  • animation = new TranslateAnimation(position_two, position_one, 0, 0);  tvTabFriends.setTextColor(resources.getColor(R.color.lightwhite)); 
  • } else if (currIndex == 3) {  animation = new TranslateAnimation(position_three, position_one, 0, 0); 
  • tvTabChat.setTextColor(resources.getColor(R.color.lightwhite));  } 
  • tvTabGroups.setTextColor(resources.getColor(R.color.white));  break; 
  • case 2:  if (currIndex == 0) { 
  • animation = new TranslateAnimation(0, position_two, 0, 0);  tvTabActivity.setTextColor(resources.getColor(R.color.lightwhite)); 
  • } else if (currIndex == 1) {  animation = new TranslateAnimation(position_one, position_two, 0, 0); 
  • tvTabGroups.setTextColor(resources.getColor(R.color.lightwhite));  } else if (currIndex == 3) { 
  • animation = new TranslateAnimation(position_three, position_two, 0, 0);  tvTabChat.setTextColor(resources.getColor(R.color.lightwhite)); 
  • }  tvTabFriends.setTextColor(resources.getColor(R.color.white)); 
  • break;  case 3: 
  • if (currIndex == 0) {  animation = new TranslateAnimation(0, position_three, 0, 0); 
  • tvTabActivity.setTextColor(resources.getColor(R.color.lightwhite));  } else if (currIndex == 1) { 
  • animation = new TranslateAnimation(position_one, position_three, 0, 0);  tvTabGroups.setTextColor(resources.getColor(R.color.lightwhite)); 
  • } else if (currIndex == 2) {  animation = new TranslateAnimation(position_two, position_three, 0, 0); 
  • tvTabFriends.setTextColor(resources.getColor(R.color.lightwhite));  } 
  • tvTabChat.setTextColor(resources.getColor(R.color.white));  break; 
  • }  currIndex = arg0; 
  • animation.setFillAfter(true);  animation.setDuration(300); 
  • ivBottomLine.startAnimation(animation);  } 
  • @Override  public void onPageScrolled(int arg0, float arg1, int arg2) { 
  • }  @Override 
  • public void onPageScrollStateChanged(int arg0) {  }