使用TabActivity 实现滑动翻页(动画)和标签置底与定制效果

本文详细介绍了如何使用TabActivity实现动画效果,并提供了核心代码实现。通过自定义方法扩展TabActivity,可以轻松实现各种预想的效果。文章还附上了源代码链接,方便读者深入研究。

先看效果图:

\
 

TabActivity 并不难用,只需要你自己去扩展一些他的方法,就可以达到你自己想到效果。不多说了,把实现动画的部分贴出现,其他的自己看源码吧。
核心代码:

  @Override
  public void setCurrentTab(int index) {
  int mCurrentTabID = getCurrentTab();
  if (null != getCurrentView()) {
  // 第一次设置 Tab 时,该值为 null。
  if (isOpenAnimation) {
  if (mCurrentTabID == (mTabCount - 1) && index == 0) {
  getCurrentView().startAnimation(slideLeftOut);
  } else if (mCurrentTabID == 0 && index == (mTabCount - 1)) {
  getCurrentView().startAnimation(slideRightOut);
  } else if (index > mCurrentTabID) {
  getCurrentView().startAnimation(slideLeftOut);
  } else if (index < mCurrentTabID) {
  getCurrentView().startAnimation(slideRightOut);
  }
  }
  }
  super.setCurrentTab(index);
  if (isOpenAnimation) {
  if (mCurrentTabID == (mTabCount - 1) && index == 0) {
  getCurrentView().startAnimation(slideLeftIn);
  } else if (mCurrentTabID == 0 && index == (mTabCount - 1)) {
  getCurrentView().startAnimation(slideRightIn);
  } else if (index > mCurrentTabID) {
  getCurrentView().startAnimation(slideLeftIn);
  } else if (index < mCurrentTabID) {
  getCurrentView().startAnimation(slideRightIn);
  }
  }
  }

源代码:
 


转载:http://www.adobex.com/android/source/details/00000389.htm

转载于:https://my.oschina.net/androidcode/blog/104715

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值