我的问题是:
我自定义了一个如下 JPTabBarMainMenu 的视图,将其设置为列表视图标题的一部分。在 JPTabBarMainMenu 中有两个按钮,当我单击两个按钮之一时动画会运行。
问题是动画在 android 2.3.3 上运行得很好,但不会在 4.0.3 和 4.0.4 上运行,我猜它不会在 4.x 上运行。我不知道原因。
JPTabBarMainMenu extends FrameLayout{
代码如下:
onAnimationStart/onAnimationRepeat/onAnimationEnd won't getting called.
FrameLayout.LayoutParams params = (LayoutParams) mSlider.getLayoutParams();
JPTranslateAnimation slideRightAnimation = new MaringTranslateTranslateAnimation(params.leftMargin, tabItem.getLeft() + offset / 2, 0, 0, mSlider);
slideRightAnimation.setDuration(slideRightAnimation.computeDuration(
JPTranslateAnimation.ANIMATION_STD_DURATION, mTabLayout.getWidth()));
slideRightAnimation.setRepeatCount(0);
slideRightAnimation.setFillAfter(true);
slideRightAnimation.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
// TODO Auto-generated method stub
isRunningAnimation = true;
if(mSelectionChangedListener != null){
mSelectionChangedListener.onSelectionChangedStart(oldIndex, mCurrentTab);
}
if(oldIndex != -1){
TabItem item = mTabItems.get(oldIndex);
item.onTabItemSelected(false);
}
}
@Override
public void onAnimationRepeat(Animation animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationEnd(Animation animation) {
// TODO Auto-generated method stub
isRunningAnimation = false;
if(mSelectionChangedListener != null){
mSelectionChangedListener.onSelectioinChangedEnd(oldIndex, mCurrentTab);
}
TabItem item = mTabItems.get(mCurrentTab);
item.onTabItemSelected(true);
if(mDrawSelectorByDefault == false){
mSlider.setVisibility(View.INVISIBLE);
}
}
});
if(mSlider.getVisibility() != View.VISIBLE){
mSlider.setVisibility(View.VISIBLE);
}
mSlider.startAnimation(slideRightAnimation);