Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

快速下拉,会导致动画非常小的问题解决方案 #4

Open
FanDuiWuXiaoJiaBan opened this issue May 10, 2019 · 0 comments
Open

Comments

@FanDuiWuXiaoJiaBan
Copy link

    /**
     * 下拉过程中不断调用此方法。第一阶段从小变大的小人头动画,和第二阶段翻跟头动画都在这里设置
     */
    @Override
    public void onPullingDown(float percent, int offset, int headerHeight, int extendHeight) {
        Logger.d("percent: " + percent);

        // 下拉的百分比小于100%时,不断调用 setScale 方法改变图片大小
        if (percent < 1) {
            mImage.setScaleX(percent);
            mImage.setScaleY(percent);

            //是否执行过翻跟头动画的标记
            if (hasSetPullDownAnim) {
                hasSetPullDownAnim = false;
            }
        }

        //当下拉的高度达到Header高度100%时,开始加载正在下拉的初始动画,即翻跟头
        if (percent >= 1.0) {
            //快速下拉 percent可能会直接从 0.5直接到1,而不会一点点变大,从而导致mImage的大小还是0.5,所以应该在这设置view的本身大小
            mImage.setScaleX(1);
            mImage.setScaleY(1);

            //因为这个方法是不停调用的,防止重复
            if (!hasSetPullDownAnim) {
                mImage.setImageResource(R.drawable.anim_pull_end);
                pullDownAnim = (AnimationDrawable) mImage.getDrawable();
                pullDownAnim.start();

                hasSetPullDownAnim = true;

            }
        }
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant