我的onScrollChanged
方法ScrollView
以及y coordinate
更改onScrollChanged
方法的运行情况。我使用onScrollChanged
方法调用moveStuffOnScreen
每个像素都有moveStuffOffScreen
个。 TranslateAnimation 在这些方法中反复运行。在一些Android设备上拨打过多电话后,我的其他视图(特别是 Viewpagers )突然消失。(三星Galaxy Ace,三星Galaxy Mini等设备)。如何避免此问题?
private class TopBarAnimationOnScrollListener extends ScrollListener {
@Override
public void onScrollChanged(int x, int y, int oldX, int oldY) {
// method calls
}
}
void moveStuffOnScreen()
{
if (_isMovingUpToBeOnScreen)
return;
_isMovingUpToBeOnScreen = true;
resetTopBarPositionToInitial();
TranslateAnimation translateAnimationOn = new TranslateAnimation(0, 0, initialRelativeLayoutHeaderHomeSmallTop - relativeLayoutHeaderHomeSmall.getHeight(),
initialRelativeLayoutHeaderHomeSmallTop);
translateAnimationOn.setFillAfter(true);
translateAnimationOn.setDuration(300);
relativeLayoutHeaderHomeSmall.setAnimation(translateAnimationOn);
}
void moveStuffOffScreen() {
if (!_isMovingUpToBeOnScreen)
return;
_isMovingUpToBeOnScreen = false;
resetTopBarPositionToInitial();
TranslateAnimation translateAnimationOff = new TranslateAnimation(0, 0, initialRelativeLayoutHeaderHomeSmallTop, initialRelativeLayoutHeaderHomeSmallTop
- relativeLayoutHeaderHomeSmall.getHeight());
translateAnimationOff.setFillAfter(true);
translateAnimationOff.setDuration(300);
relativeLayoutHeaderHomeSmall.setAnimation(translateAnimationOff);
}