TranslateAnimation后,Android Viewpager消失

时间:2013-12-13 14:46:05

标签: android android-viewpager

我的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);

    }

0 个答案:

没有答案