tabhost中activity跳转动画不显示的解决办法
【1】如果是tabhost中的activity跳到其他的activity,用这篇blog的方法即可
http://blog.sina.com.cn/s/blog_8db8914301010t31.html
【2】如果是tabhost里面的两个activity
那么用以下代码
getTabHost().setOnTabChangedListener(new OnTabChangeListener() {
public void onTabChanged(String tabId)
{
View currentView = getTabHost().getCurrentView();
if (getTabHost().getCurrentTab() > currentTab)
{
currentView.setAnimation( inFromRightAnimation() );
}
else
{
currentView.setAnimation( outToRightAnimation() );
}
currentTab = getTabHost().getCurrentTab();
}
});
public Animation inFromRightAnimation()
{
Animation inFromRight = new TranslateAnimation(
Animation.RELATIVE_TO_PARENT, +1.0f,
Animation.RELATIVE_TO_PARENT, 0.0f,
Animation.RELATIVE_TO_PARENT, 0.0f,
Animation.RELATIVE_TO_PARENT, 0.0f);
inFromRight.setDuration(240);
inFromRight.setInterpolator(new AccelerateInterpolator());
return inFromRight;
}
public Animation outToRightAnimation()
{
Animation outtoLeft = new TranslateAnimation(
Animation.RELATIVE_TO_PARENT, -1.0f,
Animation.RELATIVE_TO_PARENT, 0.0f,
Animation.RELATIVE_TO_PARENT, 0.0f,
Animation.RELATIVE_TO_PARENT, 0.0f);
outtoLeft.setDuration(240);
outtoLeft.setInterpolator(new AccelerateInterpolator());
return outtoLeft;
}